2
我試圖通過儘可能多地組合和縮小來超級優化PWA。我的應用程序主要是基於一個google tutorial的服務人員 - 正因爲如此我有代碼,如這在我的服務人員:使用gulp更新服務人員配置
var filesToCache = [
'/',
'/index.html',
'/scripts/app.js',
'/styles/inline.css'
];
self.addEventListener('install', function(e) {
console.log('[ServiceWorker] Install');
e.waitUntil(
caches.open(cacheName).then(function(cache) {
console.log('[ServiceWorker] Caching app shell');
return cache.addAll(filesToCache);
})
);
});
我有一個gulpfile.js
其中,除其他事項外使用gulp-smoosher
在生成過程中內嵌我的CSS :
<!-- smoosh -->
<link rel="stylesheet" type="text/css" href="styles/inline.css">
<!-- endsmoosh -->
偉大的工程 - 它直接內聯我的CSS到HTML - 但顯然我filesToCache
在我serviceworker現在有了在構建不會存在的條目
var filesToCache = [
'/',
'/index.html',
'/scripts/app.js',
'/styles/inline.css' // <!--- this shouldn't be here in the build
];
是否有任何選項,使用一個吞嚥任務或其他方式(也許某種配置這可以在生成更新)來解決這個問題?