I want to create a new folder called reports, which should not be part of the output.path of the webpack bundle. It should be a separate path, that I can choose with an option, to generate the stats.json file there.
How do you use this module? As CLI utility or as plugin?
As a plugin, with options
If CLI, what command was used? (e.g. webpack-bundle-analyzer -O path/to/stats.json)
webpack-bundle-analyzer ./dist/stats.json (Only for reading the generated file with a custom npm script.)
If plugin, what options were provided? (e.g. new BundleAnalyzerPlugin({ analyzerMode: 'disabled', generateStatsFile: true }))
{
generateStatsFile: true,
analyzerMode: 'static',
openAnalyzer: false
}
What other Webpack plugins were used?
CopyWebpackPlugin
SpriteLoaderPlugin
It would be nice to also attach webpack stats file.
It can be generated using these options:
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
// Excludes module sources from stats file so there won't be any sensitive data
statsOptions: { source: false }
})`
stats.json will be created in Webpack bundle output directory.
Did you try using statsFilename: '../../some/other/dir/stats.json way? The path is relative to the build output directory, but I think you can traverse from there to another directory.
You can also pass an absolute filepath for statsFilename option to generate the stats.json to any directory.
Let me know if these solutions work for you, or if you have additional questions. I'm going to close this issue for now as I think we already support what you're asking :relaxed:
Thx, it is working as expected. It wasn't clear. I should have test it before. Thx.
Most helpful comment
Did you try using
statsFilename: '../../some/other/dir/stats.jsonway? The path is relative to the build output directory, but I think you can traverse from there to another directory.