-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnext.config.js
66 lines (63 loc) · 2 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const OfflinePlugin = require('offline-plugin');
const fs = require('fs');
module.exports = {
webpack: (config, { dev }) => {
const prod = !dev;
// Offline support
if (dev || prod) {
config.plugins.push(
new OfflinePlugin({
publicPath: '/',
relativePaths: false,
externals: ['/', '/manifest.html'],
rewrites: function 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 * 5, // (five minutes)
__tests: dev ? { ignoreRuntime: true } : {}, // hack to circumvent check of offlineplugin
ServiceWorker: null, // not implemented (yet)
AppCache: {
directory: './',
events: true,
},
})
// new SWPrecacheWebpackPlugin({
// filename: 'sw.js',
// minify: true,
// staticFileGlobsIgnorePatterns: [/\.next\//],
// staticFileGlobs: [
// 'static/**/*' // Precache all static files by default
// ],
// forceDelete: true,
// runtimeCaching: [
// // Example with different handlers
// {
// handler: 'fastest',
// urlPattern: /[.](png|jpg|css)/
// },
// {
// handler: 'networkFirst',
// urlPattern: /^http.*/ //cache all files
// }
// ]
// })
);
}
return config;
},
};