-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathnext.config.js
34 lines (30 loc) · 1.03 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
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') // eslint-disable-line
const { ANALYZE } = process.env
const pro = process.env.NODE_ENV === 'production'
const test = process.env.NODE_TEST === 'test'
// 开发模式下的页面缓存
// SSR页面缓存配置 https://github.com/zeit/next.js/blob/canary/examples/ssr-caching/server.js
const onDemandEntries = {
// period (in ms) where the server will keep pages in the buffer
maxInactiveAge: 25 * 1000,
// number of pages that should be kept simultaneously without being disposed
pagesBufferLength: 2,
}
module.exports = {
useFileSystemPublicRoutes: false,
assetPrefix: pro ? (test ? '' : 'http://public.duduapp.net/finance/static') : '',
...(!pro && !test && { onDemandEntries }),
exportPathMap: () => ({
'/': { page: '/' },
}),
webpack: (config) => {
if (ANALYZE) {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: 7777,
openAnalyzer: true,
}))
}
return config
},
}