How to add custom files which not generated by webpack into precache list?
JounQin opened this issue · 4 comments
- I'm submitting a bug report
- I'm submitting a feature request
- I'm submitting a support request
webpack version:
3.10.0
sw-precache-webpack-plugin version:
0.11.4
Please tell us about your environment:
macOS 10.13.3
Browser:
Chrome 64
Current behavior:
No way to add custom file which is not generated by webpack into precache list
Expected/desired behavior:
Add an option to add custom files, webpack vendors dll
for example
https://webpack.js.org/plugins/dll-plugin/
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with your:
Webpack configuration:
https://github.com/JounQin/Rubick/blob/master/build/vue-client.ts#L66-L84
Does importScripts
fulfill this behavior?
I am also wondering about this feature. I'm trying to cache a font from Google Web Fonts:
https://fonts.googleapis.com/icon?family=Material+Icons
Oh I see, @MikaelEdebro and @JounQin, you want to add additional files to the be precached. Sorry, importScripts
is for adding code to your service worker. If you just want to cache things like Google web fonts or any file not emitted by webpack, you want to use a runtimeCaching strategy. Something like this for webfonts:
runtimeCaching: [
{
handler: 'cacheFirst',
urlPattern: /^https:\/\/fonts\.googleapis\.com\/icon/,
options: {
cache: {
maxEntries: 10,
name: 'fonts',
},
},
},
],