-
-
Save bm2ilabs/1c8c344178423820eabb37b5e70610c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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