Webpack-bundle-analyzer: Option to change the output directory

Created on 23 May 2018  路  4Comments  路  Source: webpack-contrib/webpack-bundle-analyzer

Issue description

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.

Technical info

  • Webpack Bundle Analyzer version: 2.13.1
  • Webpack version: 3.6.0
  • Node.js version: 8.9.4
  • npm/yarn version: 5.6.0
  • OS: Windows 10 (64 Bit)

Debug info

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.

Needs details / reproduction Discussion

Most helpful comment

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.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings