This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
executable file
·67 lines (59 loc) · 2.27 KB
/
webpack.config.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
// This is for dev, watch and build (production)
const Encore = require('@symfony/webpack-encore');
const encoreConfigure = require('./webpack.base.config');
const WorkboxPlugin = require('workbox-webpack-plugin');
const merge = require('webpack-merge');
process.env.NODE_ENV = process.env.NODE_ENV || (Encore.isProduction() ? 'production' : 'development');
encoreConfigure(Encore);
if (Encore.isProduction()) {
Encore.addPlugin(new WorkboxPlugin.GenerateSW({
swDest: '../service-worker.js',
importWorkboxFrom: 'local',
chunks: ['public', 'admin'],
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling "old" SWs to hang around
clientsClaim: true,
skipWaiting: true,
maximumFileSizeToCacheInBytes: 20 * 1024 * 1024, // 20mb
// chunk name is not used because these are refreshed
// every time the service worker script is updated
importScripts: ['/js/src/service_worker_import.js'],
runtimeCaching: [
{
urlPattern: /()/,
handler: 'networkFirst',
options: {
cacheName: 'pages',
},
},
{
urlPattern: /\.(?:js|css|svg)$/,
handler: 'networkFirst',
options: {
cacheName: 'static-resources',
},
},
// page to show if offline
// {
// urlPattern: /(.*)/,
// // based on: https://github.com/GoogleChrome/workbox/issues/757#issuecomment-326672407
// handler: ({url, event, params}) => {
// return fetch(event.request)
// .catch((error) => {
// if (event.request.mode === 'navigate') {
// return caches.match('/offline');
// }
//
// return error;
// });
// },
// },
],
}));
}
let config = merge(Encore.getWebpackConfig(), require('./webpack.customize'));
if (Encore.isProduction()) {
config.devtool = 'source-map';
}
module.exports = config;