-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
43 lines (41 loc) · 1.27 KB
/
next.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
const OfflinePlugin = require('offline-plugin');
module.exports = {
webpack: (config, { dev }) => {
// Offline support
if (!dev) {
config.plugins.push(
new OfflinePlugin({
publicPath: '/',
relativePaths: false,
externals: ['/', '/manifest.html'],
rewrites(asset) {
if (
asset.indexOf('.hot-update.js') > -1 ||
asset.indexOf('build-stats.json') > -1 ||
asset === 'BUILD_ID' ||
asset.indexOf('dist/') === 0
) {
return null;
}
return asset[0] === '/'
? asset
: asset.indexOf('bundles/pages/') === 0
? `/_next/-/${asset
.replace('bundles/pages', 'page')
.replace('index.js', '')
.replace(/\.js$/, '')}`
: `/_next/-/${asset}`;
},
autoUpdate: 1000 * 60 * 60 * 5, // (five minutes)
__tests: dev ? { ignoreRuntime: true } : {}, // Hack to circumvent check of offlineplugin
ServiceWorker: {
directory: './',
events: true,
responseStrategy: 'network-first'
}
})
);
}
return config;
}
};