使用 --stats-json 构建 Angular 6 不生成 stats.json 文件

标签 angular npm webpack webpack-bundle-analyzer

我正在尝试为我的 Angular 6 应用程序生成 stats.json 文件。下面的事情我已经尝试过,但根本没有生成文件。我的系统需要有 “npm 运行”在每个 angular cli 命令之前。

  • 我跑了 “npm 运行 ng build --prod --stats-json”以及 "npm run ng build --prod --stats-json=true" .
  • 我跑了 “npm 运行 ng build --stats-json”以及 "npm run ng build --stats-json=true" (没有构建命令)。
  • 二手 “npm 运行 ng build --statsJson=true”通过引用 cli 文档。

  • 但是仍然没有生成 stats.json 文件,我想使用 webpack 包分析器读取该文件。
    欢迎在这方面提供任何帮助、建议或更正。

    下面是我的 package.json 中的脚本。

    “脚本”:{
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "gulp": "gulp",
    "bundle-report": "webpack-bundle-analyzer dist/stats.json",
    "stats": "webpack-bundle-analyzer dist/stats.json"
    

    },

    最佳答案

    我发现我的在/dist 中。
    这意味着如果您查看 git 中出现的更改,它可能会被忽略。

    关于使用 --stats-json 构建 Angular 6 不生成 stats.json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58693987/

    相关文章:

    angular - http 响应对象中没有方法

    node.js - Node 和 Angular 与 TypeScript

    node.js - Node 错误,nodeenv : couldn't find any version specified for use

    reactjs - 如何使用 webpack 转换 SVG 图标?

    javascript - 核心模块是否应该在 Angular2 中导入共享模块

    angular - angular_components,rpc和sqljocky之间的版本冲突

    node.js - npm install 在 node_modules 中创建过多的依赖项

    node.js - windows 10 socket.io安装错误

    javascript - `!!`源码中的 `script-loader`是什么意思?

    javascript - ReactJS:意外 token '<'