diff --git a/packages/service-worker/config/src/generator.ts b/packages/service-worker/config/src/generator.ts index cabd67f491..01e430c758 100644 --- a/packages/service-worker/config/src/generator.ts +++ b/packages/service-worker/config/src/generator.ts @@ -46,7 +46,7 @@ export class Generator { plainFiles.forEach(file => seenMap.add(file)); // Add the hashes. - await plainFiles.reduce(async(previous, file) => { + await[...versionedFiles, ...plainFiles].reduce(async(previous, file) => { await previous; const hash = await this.fs.hash(file); hashTable[joinUrls(this.baseHref, file)] = hash; diff --git a/packages/service-worker/config/test/generator_spec.ts b/packages/service-worker/config/test/generator_spec.ts index b03dd62cda..2511226c61 100644 --- a/packages/service-worker/config/test/generator_spec.ts +++ b/packages/service-worker/config/test/generator_spec.ts @@ -14,6 +14,7 @@ export function main() { it('generates a correct config', (done: DoneFn) => { const fs = new MockFilesystem({ '/index.html': 'This is a test', + '/test.txt': 'Another test', '/foo/test.html': 'Another test', '/ignored/x.html': 'should be ignored', }); @@ -30,7 +31,9 @@ export function main() { '/**/*.html', '!/ignored/**', // '/*.html', ], - versionedFiles: [], + versionedFiles: [ + '/**/*.txt', + ], urls: [ '/absolute/**', '/some/url?with+escaped+chars', @@ -62,7 +65,11 @@ export function main() { 'name': 'test', 'installMode': 'prefetch', 'updateMode': 'prefetch', - 'urls': ['/test/index.html', '/test/foo/test.html'], + 'urls': [ + '/test/index.html', + '/test/foo/test.html', + '/test/test.txt', + ], 'patterns': [ '\\/absolute\\/.*', '\\/some\\/url\\?with\\+escaped\\+chars', @@ -79,6 +86,7 @@ export function main() { 'version': 1, }], 'hashTable': { + '/test/test.txt': '18f6f8eb7b1c23d2bb61bff028b83d867a9e4643', '/test/index.html': 'a54d88e06612d820bc3be72877c74f257b561b19', '/test/foo/test.html': '18f6f8eb7b1c23d2bb61bff028b83d867a9e4643' }