Add svelte as a view engine to swaf #33

Merged
ashpie merged 97 commits from svelte into develop 2021-11-09 19:31:22 +01:00
4 changed files with 7 additions and 7 deletions
Showing only changes of commit 58ea522593 - Show all commits

View File

@ -47,9 +47,9 @@
}, },
view: { view: {
cache: false, cache: false,
enable_asset_cache: false,
dev: true, dev: true,
}, },
asset_cache: false,
magic_link: { magic_link: {
validity_period: 20, validity_period: 20,
}, },

View File

@ -20,7 +20,7 @@
}, },
view: { view: {
cache: true, cache: true,
enable_asset_cache: true,
dev: false, dev: false,
}, },
asset_cache: true,
} }

View File

@ -19,7 +19,7 @@ export default class FrontendToolsComponent extends ApplicationComponent {
public async start(app: Express): Promise<void> { public async start(app: Express): Promise<void> {
// Cache public assets // Cache public assets
if (config.get<boolean>('view.enable_asset_cache')) { if (config.get<boolean>('asset_cache')) {
logger.info('Caching assets from', this.viewEngine.getPublicDir(), '...'); logger.info('Caching assets from', this.viewEngine.getPublicDir(), '...');
await readdirRecursively( await readdirRecursively(
this.viewEngine.getPublicDir(), this.viewEngine.getPublicDir(),

View File

@ -58,11 +58,11 @@ export default class SvelteViewEngine extends ViewEngine {
// View // View
const actualFile = path.join(this.getBuildDir(), canonicalViewName + COMPILED_SVELTE_EXTENSION); const actualFile = path.join(this.getBuildDir(), canonicalViewName + COMPILED_SVELTE_EXTENSION);
const view = await this.fileCache.get(actualFile, config.get<boolean>('view.dev')); const view = await this.fileCache.get(actualFile, !config.get<boolean>('view.cache'));
// Root template // Root template
const templateFile = await this.resolveFileFromCanonicalName('layouts/svelte_layout.html'); const templateFile = await this.resolveFileFromCanonicalName('layouts/svelte_layout.html');
let output = await this.fileCache.get(templateFile, config.get<boolean>('view.dev')); let output = await this.fileCache.get(templateFile, !config.get<boolean>('view.cache'));
// Pre-compiled parts // Pre-compiled parts
const [ const [
@ -126,7 +126,7 @@ export default class SvelteViewEngine extends ViewEngine {
const intermediateFile = path.join(this.getBuildDir(), canonicalName); const intermediateFile = path.join(this.getBuildDir(), canonicalName);
logger.info(canonicalName + ' > ', 'Pre-compiling', file, '->', intermediateFile); logger.info(canonicalName + ' > ', 'Pre-compiling', file, '->', intermediateFile);
const source = await this.fileCache.get(file, config.get<boolean>('view.dev')); const source = await this.fileCache.get(file, !config.get<boolean>('view.cache'));
const allBackendLines: string[] = []; const allBackendLines: string[] = [];
for (const dependency of this.resolveDependencies(source, canonicalName)) { for (const dependency of this.resolveDependencies(source, canonicalName)) {
@ -198,7 +198,7 @@ export default class SvelteViewEngine extends ViewEngine {
// Read source file if code was not already provided // Read source file if code was not already provided
if (!code) { if (!code) {
const file = await this.resolveFileFromCanonicalName(canonicalViewName); const file = await this.resolveFileFromCanonicalName(canonicalViewName);
code = await this.fileCache.get(file, config.get<boolean>('view.dev')); code = await this.fileCache.get(file, !config.get<boolean>('view.cache'));
} }
// Skip replace if there is no swaf export // Skip replace if there is no swaf export