diff --git a/application/application-common.ts b/application/application-common.ts index 192c40791..54d5922cf 100644 --- a/application/application-common.ts +++ b/application/application-common.ts @@ -4,6 +4,7 @@ import fs = require("file-system"); import styleScope = require("ui/styling/style-scope"); import observable = require("data/observable"); import frame = require("ui/frame"); +import fileResolverModule = require("file-system/file-name-resolver"); var events = new observable.Observable(); global.moduleMerge(events, exports); @@ -53,5 +54,12 @@ export function loadCss() { } global.__onLiveSync = function () { + // Clear file resolver cache to respect newly added files. + fileResolverModule.clearCache(); + + // Reload app.css in case it was changed. + loadCss(); + + // Reload current page. frame.reloadPage(); } \ No newline at end of file diff --git a/file-system/file-name-resolver.d.ts b/file-system/file-name-resolver.d.ts index 2d9e5d370..5b18d44e1 100644 --- a/file-system/file-name-resolver.d.ts +++ b/file-system/file-name-resolver.d.ts @@ -12,9 +12,11 @@ declare module "file-system/file-name-resolver" { export class FileNameResolver { constructor(context: PlatformContext); resolveFileName(path: string, ext: string): string; + clearCache(): void; } export function resolveFileName(path: string, ext: string): string; + export function clearCache(): void; //@private export function findFileMatch(path: string, ext: string, candidates: Array, context: PlatformContext): string diff --git a/file-system/file-name-resolver.ts b/file-system/file-name-resolver.ts index fdf023498..b9e7c785a 100644 --- a/file-system/file-name-resolver.ts +++ b/file-system/file-name-resolver.ts @@ -126,6 +126,10 @@ export class FileNameResolver implements definition.FileNameResolver { return result; } + public clearCache(): void { + this._cache = {}; + } + private resolveFileNameImpl(path: string, ext: string): string { var result: string = null; path = fs.path.normalize(path); @@ -239,3 +243,8 @@ export function resolveFileName(path: string, ext: string): string { return resolverInstance.resolveFileName(path, ext); } +export function clearCache(): void { + if (resolverInstance) { + resolverInstance.clearCache(); + } +} \ No newline at end of file