-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
33 lines (31 loc) · 916 Bytes
/
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
const { ANALYZE } = process.env;
const pro = process.env.NODE_ENV === 'production';
const test = process.env.NODE_TEST === 'test';
const path = require('path');
const webpackBundleAnalyzer = require('webpack-bundle-analyzer');
module.exports = {
useFileSystemPublicRoutes: false,
webpack: (config, {
isServer,
}) => {
const newConfig = Object.assign({}, config);
// 配置快捷操作
newConfig.resolve.alias.components = path.resolve(__dirname, './components');
newConfig.resolve.extensions.push('jsx');
// 打包分析插件
if (ANALYZE) {
const { BundleAnalyzerPlugin } = webpackBundleAnalyzer;
newConfig.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true,
}));
}
return newConfig;
},
exportPathMap: () => ({
'/': {
page: '/',
},
}),
};