From 58ea5225932bab048e08209a6cab28aee3637a9b Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 27 Apr 2021 15:08:41 +0200 Subject: [PATCH] Reorganize config params and use view.cache for caching instead of view.dev --- config/default.json5 | 2 +- config/production.json5 | 2 +- src/components/FrontendToolsComponent.ts | 2 +- src/frontend/SvelteViewEngine.ts | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/default.json5 b/config/default.json5 index e3b1975..652d737 100644 --- a/config/default.json5 +++ b/config/default.json5 @@ -47,9 +47,9 @@ }, view: { cache: false, - enable_asset_cache: false, dev: true, }, + asset_cache: false, magic_link: { validity_period: 20, }, diff --git a/config/production.json5 b/config/production.json5 index b14c43d..6d48686 100644 --- a/config/production.json5 +++ b/config/production.json5 @@ -20,7 +20,7 @@ }, view: { cache: true, - enable_asset_cache: true, dev: false, }, + asset_cache: true, } diff --git a/src/components/FrontendToolsComponent.ts b/src/components/FrontendToolsComponent.ts index 88204ff..f962ce0 100644 --- a/src/components/FrontendToolsComponent.ts +++ b/src/components/FrontendToolsComponent.ts @@ -19,7 +19,7 @@ export default class FrontendToolsComponent extends ApplicationComponent { public async start(app: Express): Promise { // Cache public assets - if (config.get('view.enable_asset_cache')) { + if (config.get('asset_cache')) { logger.info('Caching assets from', this.viewEngine.getPublicDir(), '...'); await readdirRecursively( this.viewEngine.getPublicDir(), diff --git a/src/frontend/SvelteViewEngine.ts b/src/frontend/SvelteViewEngine.ts index f8cbf12..6cd76b4 100644 --- a/src/frontend/SvelteViewEngine.ts +++ b/src/frontend/SvelteViewEngine.ts @@ -58,11 +58,11 @@ export default class SvelteViewEngine extends ViewEngine { // View const actualFile = path.join(this.getBuildDir(), canonicalViewName + COMPILED_SVELTE_EXTENSION); - const view = await this.fileCache.get(actualFile, config.get('view.dev')); + const view = await this.fileCache.get(actualFile, !config.get('view.cache')); // Root template const templateFile = await this.resolveFileFromCanonicalName('layouts/svelte_layout.html'); - let output = await this.fileCache.get(templateFile, config.get('view.dev')); + let output = await this.fileCache.get(templateFile, !config.get('view.cache')); // Pre-compiled parts const [ @@ -126,7 +126,7 @@ export default class SvelteViewEngine extends ViewEngine { const intermediateFile = path.join(this.getBuildDir(), canonicalName); logger.info(canonicalName + ' > ', 'Pre-compiling', file, '->', intermediateFile); - const source = await this.fileCache.get(file, config.get('view.dev')); + const source = await this.fileCache.get(file, !config.get('view.cache')); const allBackendLines: string[] = []; 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 if (!code) { const file = await this.resolveFileFromCanonicalName(canonicalViewName); - code = await this.fileCache.get(file, config.get('view.dev')); + code = await this.fileCache.get(file, !config.get('view.cache')); } // Skip replace if there is no swaf export