1 | module.exports = ({ enabled = true } = {}) => (nextConfig = {}) => {
|
2 | return Object.assign({}, nextConfig, {
|
3 | webpack(config, options) {
|
4 | if (enabled) {
|
5 | const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
|
6 | config.plugins.push(
|
7 | new BundleAnalyzerPlugin({
|
8 | analyzerMode: 'static',
|
9 | reportFilename: options.isServer
|
10 | ? '../analyze/server.html'
|
11 | : './analyze/client.html',
|
12 | })
|
13 | )
|
14 | }
|
15 |
|
16 | if (typeof nextConfig.webpack === 'function') {
|
17 | return nextConfig.webpack(config, options)
|
18 | }
|
19 | return config
|
20 | },
|
21 | })
|
22 | }
|