-
Notifications
You must be signed in to change notification settings - Fork 27.8k
/
Copy pathindex.js
27 lines (26 loc) · 870 Bytes
/
index.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
module.exports =
({ enabled = true, openAnalyzer, analyzerMode } = {}) =>
(nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack(config, options) {
if (enabled) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: analyzerMode || 'static',
openAnalyzer,
reportFilename: !options.nextRuntime
? `./analyze/client.html`
: `../${options.nextRuntime === 'nodejs' ? '../' : ''}analyze/${
options.nextRuntime
}.html`,
})
)
}
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
},
})
}