Skip to content

Instantly share code, notes, and snippets.

@bm2ilabs
Created November 12, 2018 17:40
Show Gist options
  • Save bm2ilabs/1c8c344178423820eabb37b5e70610c1 to your computer and use it in GitHub Desktop.
Save bm2ilabs/1c8c344178423820eabb37b5e70610c1 to your computer and use it in GitHub Desktop.
const WorkboxPlugin = require('workbox-webpack-plugin');
module.exports = require('@spatie/webpack')({
entry: {
'js/app': './resources/js/app.js',
'css/app': './resources/css/app.css',
'sass/app': './resources/sass/app.scss',
},
plugins: [
// Other plugins...
new WorkboxPlugin.GenerateSW({
// Exclude images from the precache
exclude: [/\.(?:png|jpg|jpeg|svg)$/],
// Define runtime caching rules.
runtimeCaching: [{
// Match any request ends with .png, .jpg, .jpeg or .svg.
urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
// Apply a cache-first strategy.
handler: 'cacheFirst',
options: {
// Use a custom cache name.
cacheName: 'images',
// Only cache 10 images.
expiration: {
maxEntries: 10,
},
},
}],
})
]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment