-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
45 lines (41 loc) · 2.08 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
const path = require('path');
const NextWorkboxWebpackPlugin = require('next-workbox-webpack-plugin');
module.exports = {
poweredByHeader: false,
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
// Important: return the modified config
config.resolve.alias = {
...(config.resolve.alias || {}),
Assets: path.resolve(__dirname, "assets"),
Components: path.resolve(__dirname, "components"),
Config: path.resolve(__dirname, "config"),
Flux: path.resolve(__dirname, "flux"),
Layouts: path.resolve(__dirname, "layouts"),
Utils: path.resolve(__dirname, "utils"),
};
if (!isServer && !dev) {
config.plugins.push(new NextWorkboxWebpackPlugin({
// must, see next.config.js below
buildId,
// optional, next.js dist path as compiling. most of cases you don't need to fix it.
distDir: '.next',
// optional, which version of workbox will be used in between 'local' or 'cdn'. 'local'
// option will help you use copy of workbox libs in localhost.
importWorkboxFrom: 'local',
// optional ,whether make a precache manifest of pages and chunks of Next.js app or not.
precacheManifest: true,
// optional, whether delete workbox path generated by the plugin.
removeDir: true,
// optional, path for generating sw files in build, `./static/workbox` is default
swDestRoot: './static/',
// optional, path for serving sw files in build, `./static/workbox` is default
swURLRoot: '/static'
// optional, you can use workbox-build options. except swDest because of output location is fixed in 'static/workbox',
// ...WorkboxBuildOptions,
}));
}
return config
},
}