From 407d43fa8e1d0e6a3d59fdec6a02ce50b1296d93 Mon Sep 17 00:00:00 2001 From: Cyrille Tuzi Date: Thu, 10 Aug 2017 14:39:35 +0200 Subject: [PATCH 1/2] fix(@angular/cli): ignore system files in service worker Related to angular/mobile-toolkit#180 When copying the assets, the CLI includes system files (e.g. .DS_Store and Thumbs.db). As a consequence, they are included in the service worker manifest as files to cache. But such file may (and should) not be deployed to the server, then a file will be missing, then the service worker installation will fail and so all the offline feature won't work. This PR makes the CLI ensure the service worker will ignore these system files. --- packages/@angular/cli/models/webpack-configs/production.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/@angular/cli/models/webpack-configs/production.ts b/packages/@angular/cli/models/webpack-configs/production.ts index 7535e7417961..72d3e2d85e77 100644 --- a/packages/@angular/cli/models/webpack-configs/production.ts +++ b/packages/@angular/cli/models/webpack-configs/production.ts @@ -72,8 +72,11 @@ export const getProdConfig = function (wco: WebpackConfigOptions) { // Load the Webpack plugin for manifest generation and install it. const AngularServiceWorkerPlugin = require('@angular/service-worker/build/webpack') .AngularServiceWorkerPlugin; + + // Add baseHref in manifest and ignore system files extraPlugins.push(new AngularServiceWorkerPlugin({ baseHref: buildOptions.baseHref || '/', + 'static.ignore': ['^\\.DS_Store$', '^Thumbs\\.db$'], })); // Copy the worker script into assets. From d5bca40ef3cd8aa44eda945ae18e66927dad6d12 Mon Sep 17 00:00:00 2001 From: Cyrille Tuzi Date: Fri, 11 Aug 2017 09:15:25 +0200 Subject: [PATCH 2/2] fix lint issue --- packages/@angular/cli/models/webpack-configs/production.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@angular/cli/models/webpack-configs/production.ts b/packages/@angular/cli/models/webpack-configs/production.ts index 72d3e2d85e77..5b1e319fda4b 100644 --- a/packages/@angular/cli/models/webpack-configs/production.ts +++ b/packages/@angular/cli/models/webpack-configs/production.ts @@ -72,7 +72,7 @@ export const getProdConfig = function (wco: WebpackConfigOptions) { // Load the Webpack plugin for manifest generation and install it. const AngularServiceWorkerPlugin = require('@angular/service-worker/build/webpack') .AngularServiceWorkerPlugin; - + // Add baseHref in manifest and ignore system files extraPlugins.push(new AngularServiceWorkerPlugin({ baseHref: buildOptions.baseHref || '/',