webpack-bundle-analyzer
webpack-bundle-analyzer copied to clipboard
Add support for writing multiple reports at once
We are adding support for a new option called reports which accepts an
array of reports:
new BundleAnalyzerPlugin({
analyzerMode: "static",
reports: [
{ type: "json", filename: "my-report.json" },
{ type: "html", filename: "my-report.html" },
],
});
Users of the analyzerMode in json should migrate from:
new BundleAnalyzerPlugin({
analyzerMode: "json",
reportFilename: "my-report.json",
});
to
new BundleAnalyzerPlugin({
analyzerMode: "static",
reports: [{ type: "json", filename: "my-report.json" }],
});
Users of the analyzerMode with html should migrate from:
new BundleAnalyzerPlugin({
analyzerMode: "static",
reportFileName: "my-report.html",
});
to
new BundleAnalyzerPlugin({
analyzerMode: "static",
reports: [{ type: "html", filename: "my-report.html" }],
});
In order to help with the migration, these config changes will pe printed with a logger warning, while we internally being rewritten to the new format so that this isn't a breaking change.
@valscion This is code only for now, if you are satisfied with the code changes, I will update the docs.
I don't know if this comment by @th0r applies here: https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/375#issuecomment-828378309
I'll let @th0r communicate here if this direction is good or not.
Hmm yeah, I think adding support for
analyzerModepossibly being an array would be reasonable.Well, I think we can do that, but it will require a change to
reportFilenameoption to be able to return different filenames for different report types e.g. allow to make it a function(reportType) => <reportFilename>(which won't work for CLI) or an object{<reportType>: <reportFilename>}. Anyway, options becomes a mess... We definitely need to ship a new major version with completely revised API with pluggable external reporters.