Reorganize config params and use view.cache for caching instead of view.dev
This commit is contained in:
parent
faab9e4894
commit
58ea522593
@ -47,9 +47,9 @@
|
||||
},
|
||||
view: {
|
||||
cache: false,
|
||||
enable_asset_cache: false,
|
||||
dev: true,
|
||||
},
|
||||
asset_cache: false,
|
||||
magic_link: {
|
||||
validity_period: 20,
|
||||
},
|
||||
|
@ -20,7 +20,7 @@
|
||||
},
|
||||
view: {
|
||||
cache: true,
|
||||
enable_asset_cache: true,
|
||||
dev: false,
|
||||
},
|
||||
asset_cache: true,
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ export default class FrontendToolsComponent extends ApplicationComponent {
|
||||
|
||||
public async start(app: Express): Promise<void> {
|
||||
// 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(), '...');
|
||||
await readdirRecursively(
|
||||
this.viewEngine.getPublicDir(),
|
||||
|
@ -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<boolean>('view.dev'));
|
||||
const view = await this.fileCache.get(actualFile, !config.get<boolean>('view.cache'));
|
||||
|
||||
// Root template
|
||||
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
|
||||
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<boolean>('view.dev'));
|
||||
const source = await this.fileCache.get(file, !config.get<boolean>('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<boolean>('view.dev'));
|
||||
code = await this.fileCache.get(file, !config.get<boolean>('view.cache'));
|
||||
}
|
||||
|
||||
// Skip replace if there is no swaf export
|
||||
|
Loading…
Reference in New Issue
Block a user