add logLevel support to @next/bundle-analyzer (#59228)

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
This commit is contained in:
quisi.do 2023-12-06 14:21:23 -08:00 committed by GitHub
parent 7a733dfd34
commit 19fa1fa579
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -4,6 +4,12 @@ declare function NextBundleAnalyzer(options?: {
enabled?: boolean enabled?: boolean
openAnalyzer?: boolean openAnalyzer?: boolean
analyzerMode?: 'json' | 'static' analyzerMode?: 'json' | 'static'
/**
* Log level. Can be 'info', 'warn', 'error' or 'silent'.
* @default 'info'
*/
logLevel?: 'info' | 'warn' | 'error' | 'silent' | undefined
}): (config?: NextConfig) => NextConfig }): (config?: NextConfig) => NextConfig
export = NextBundleAnalyzer export = NextBundleAnalyzer

View file

@ -1,5 +1,5 @@
module.exports = module.exports =
({ enabled = true, openAnalyzer, analyzerMode } = {}) => ({ enabled = true, logLevel, openAnalyzer, analyzerMode } = {}) =>
(nextConfig = {}) => { (nextConfig = {}) => {
return Object.assign({}, nextConfig, { return Object.assign({}, nextConfig, {
webpack(config, options) { webpack(config, options) {
@ -8,6 +8,7 @@ module.exports =
config.plugins.push( config.plugins.push(
new BundleAnalyzerPlugin({ new BundleAnalyzerPlugin({
analyzerMode: analyzerMode || 'static', analyzerMode: analyzerMode || 'static',
logLevel,
openAnalyzer, openAnalyzer,
reportFilename: !options.nextRuntime reportFilename: !options.nextRuntime
? `./analyze/client.html` ? `./analyze/client.html`