Skip to content

Commit

Permalink
Merge pull request #317 from Kitware/update-workbox
Browse files Browse the repository at this point in the history
fix(webpack): Update workbox caching strategy
  • Loading branch information
floryst authored Apr 15, 2020
2 parents 549f125 + abe0a11 commit 708db10
Show file tree
Hide file tree
Showing 4 changed files with 679 additions and 65 deletions.
23 changes: 18 additions & 5 deletions build/webpack.base.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { GenerateSW } = require('workbox-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
Expand All @@ -24,7 +25,7 @@ module.exports = {
}, externals.getExternalEntries(paths.externals)),
output: {
path: paths.output,
filename: '[name].js',
filename: '[name].[contenthash].js',
libraryTarget: 'umd',
},
module: {
Expand Down Expand Up @@ -103,6 +104,9 @@ module.exports = {
].concat(vtkRules.core.rules),
},
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['**/*', '!version.js'],
}),
new VueLoaderPlugin(),
new VuetifyLoaderPlugin(),
new WriteFilePlugin(),
Expand Down Expand Up @@ -130,10 +134,19 @@ module.exports = {
flatten: true,
},
]),
new WorkboxPlugin({
globIgnores: ['serviceWorker.js'],
swSrc: path.join(paths.externals, 'Workbox', 'serviceWorker.js'),
new GenerateSW({
cacheId: 'paraview-glance-',
cleanupOutdatedCaches: true,
include: [/\.js$/],
exclude: ['serviceWorker.js'],
swDest: path.join(paths.output, 'serviceWorker.js'),
skipWaiting: true,
runtimeCaching: [
{
handler: 'CacheFirst',
urlPattern: /(\.css|\.ttf|\.eot|\.woff|\.js|\.png|\.svg|\.wasm)$/,
},
],
}),
],
resolve: {
Expand Down
2 changes: 1 addition & 1 deletion build/webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = merge.smart(baseConfig, {
inject: false,
}),
new MiniCssExtractPlugin({
filename: '[name].css',
filename: '[name].[contenthash].css',
ignoreOrder: false,
}),
],
Expand Down
Loading

0 comments on commit 708db10

Please sign in to comment.