create-react-app集成webpack-bundle

作者: 进击的三文鱼 | 来源:发表于2019-06-18 21:35 被阅读11次

    1 安装webpack-bundle-analyzer
    命令 yarn add webpack-bundle-analyzer
    2 配置webpack.config.dev.js

    const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
     module.exports = {
      plugins: [
        new BundleAnalyzerPlugin()
      ]
     }
    

    3 package.json 配置

      "analyz": "set NODE_ENV=production npm_config_report=true npm run start"
    

    需要注意“配置时 前面要加的set 否则会报错”
    4 执行yarn start 启动项目 会自动访问http://127.0.0.1:8888
    查看到打包详情

    image.png

    相关文章

      网友评论

        本文标题:create-react-app集成webpack-bundle

        本文链接:https://www.haomeiwen.com/subject/geoqqctx.html