summaryrefslogtreecommitdiff
path: root/webpack.config.js
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2018-06-08 21:26:00 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2018-12-13 17:09:16 +0100
commit505a67dc32206a0c603258d856fcbe00e53fc1f5 (patch)
tree4b5dae6ebdb92897fa04c3c6c98f284c52795ddf /webpack.config.js
parent97ec1efce2bdffd7eeadbbb024fc6f3ffaebfb1e (diff)
downloadbrokentalents-505a67dc32206a0c603258d856fcbe00e53fc1f5.tar.gz
brokentalents-505a67dc32206a0c603258d856fcbe00e53fc1f5.zip
Upgrade from SW precache to workbox
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/webpack.config.js b/webpack.config.js
index 25ad82c..0987ccc 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -5,12 +5,13 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const PurgecssPlugin = require('purgecss-webpack-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
-const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
+const workboxPlugin = require('workbox-webpack-plugin');
module.exports = {
entry: path.resolve(__dirname, 'src/index.js'),
output: {
path: path.resolve(__dirname, 'dist/'),
+ publicPath: '/dist/',
filename: 'build.js',
},
module: {
@@ -46,16 +47,14 @@ module.exports = {
}),
new OptimizeCssAssetsPlugin(),
].concat(process.env.NODE_ENV == 'production' ? [
- new SWPrecacheWebpackPlugin({
- cacheId: 'brokentalents-1',
- filepath: './service-worker.js',
- staticFileGlobs: [
- 'index.html',
- 'dist/**/*',
- 'data/*/report.json',
- 'data/*/metadata.json',
- ],
- minify: true,
+ new workboxPlugin.GenerateSW({
+ cacheId: 'brokentalents',
+ swDest: '../service-worker.js',
+ importWorkboxFrom: 'local',
+ clientsClaim: true,
+ skipWaiting: true,
+ globDirectory: '.',
+ globPatterns: ['dist/**/*.{jpg,png}'],
}),
new PurgecssPlugin({
paths: glob.sync([