Specify --json in webpack config instead of command line

大憨熊 提交于 2019-12-08 11:48:18

问题


I'm using Webpack 4 via webpack-stream / gulp. I'd like to write stats as a JSON file, like I would with webpack --json > stats.json, but using my current tooling.

Ideally, I would simply set the option in the config object I pass to webpack-stream, but I'm open to other options.


回答1:


It just so happens I'm using webpack-bundle-analyzer, which provides the option to write out stats.json for me. Here's the config:

{
    // ...
    plugins: [
        new analyzer.BundleAnalyzerPlugin({
            // writes to <webpack output dir>/stats.json by default
            generateStatsFile: true  
        }),
    ]
    // ...
}

The more general solution is to use webpack-stats-plugin.



来源:https://stackoverflow.com/questions/50876533/specify-json-in-webpack-config-instead-of-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!