Unverified Commit 115b6ad9 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Allow configuring analyzerMode in bundle-analyzer (#47468)

It's valid to want to output JSON instead of HTML for the bundle
analyzer so we can expose this specific config the same as
`openAnalyzer`. cc @mknichel
parent 40ce6219
import type { NextConfig } from 'next' import type { NextConfig } from 'next'
declare const NextBundleAnalyzer = declare function NextBundleAnalyzer(options?: {
(options?: { enabled?: boolean; openAnalyzer?: boolean }) => enabled?: boolean
(config?: NextConfig) => openAnalyzer?: boolean
NextConfig analyzerMode?: 'json' | 'static'
}): (config?: NextConfig) => NextConfig
export = NextBundleAnalyzer export = NextBundleAnalyzer
module.exports = module.exports =
({ enabled = true, openAnalyzer = true } = {}) => ({ enabled = true, openAnalyzer, analyzerMode } = {}) =>
(nextConfig = {}) => { (nextConfig = {}) => {
return Object.assign({}, nextConfig, { return Object.assign({}, nextConfig, {
webpack(config, options) { webpack(config, options) {
...@@ -7,7 +7,7 @@ module.exports = ...@@ -7,7 +7,7 @@ module.exports =
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
config.plugins.push( config.plugins.push(
new BundleAnalyzerPlugin({ new BundleAnalyzerPlugin({
analyzerMode: 'static', analyzerMode: analyzerMode || 'static',
openAnalyzer, openAnalyzer,
reportFilename: !options.nextRuntime reportFilename: !options.nextRuntime
? `./analyze/client.html` ? `./analyze/client.html`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment