-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
29 lines (26 loc) · 1010 Bytes
/
webpack.config.prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const CleanPlugin = require('clean-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const config = {
plugins: [
new CleanPlugin(['build'], {
allowExternal: true
}),
new WorkboxPlugin.GenerateSW({
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling "old" SWs to hang around
clientsClaim: true,
skipWaiting: true,
// Exclude images from the precache
exclude: [/\.(?:png|jpg|jpeg|svg)$/],
// Define runtime caching rules.
runtimeCaching: [{
urlPattern: /\.(?:png|jpg|jpeg|svg)$/, // Match any request ends with .png, .jpg, .jpeg or .svg.
handler: 'cacheFirst', // Apply a cache-first strategy.
options: { // Use a custom cache name.
cacheName: 'images'
},
}]
})
],
};
module.exports = config;