javascript - Angular 7 使用 ng build --prod 缩小 Assets

标签 javascript node.js angular typescript minify

/assets 中的 JavaScript 和 CSS 文件在 ng build --prod 后未缩小。有人知道如何缩小这些文件吗?我在 Angular 文档中没有看到任何内容。

最佳答案

你在生产中构建的所有东西都已经缩小了,如果它没有缩小我认为你还没有在 angular.json 中打开配置。您可以在 angular.json 中使用这些配置

"configurations": {
    "production": {
        "fileReplacements": [
            {
                "replace": "src/environments/environment.ts",
                "with": "src/environments/environment.prod.ts"
            }
        ],
        "optimization": true,
        "outputHashing": "all",
        "sourceMap": false,
        "extractCss": true,
        "namedChunks": false,
        "aot": true,
        "extractLicenses": true,
        "vendorChunk": true,
        "buildOptimizer": true,
        "serviceWorker": true,
        "deleteOutputPath": true,
        "budgets": [
            {
                "type": "initial",
                "maximumWarning": "2mb",
                "maximumError": "5mb"
            }
        ]
    }
}

然后再次运行ng build --prod

关于javascript - Angular 7 使用 ng build --prod 缩小 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57886872/

相关文章:

javascript - Webpack sequelize,sqlite3 错误找不到模块 sqlite3

javascript - 内联行编辑的 onSuccess 事件未触发

javascript - 使用 Moment JS : Cannot find module "./locale" 创建 React 应用程序

javascript - 什么是 gulp 任务异步运行提示?

angular - 在 VSTS 中包含代码覆盖率报告,VSTS 是否必须使用测试适配器?

arrays - 使用 'ngFor' 指令浏览月份数组

javascript - 将 json 数据发送到网格

javascript - 如何使用 Mocha、Chai 和 Sinon 正确测试 Express Controller 方法

node.js - 为客户端部署压缩 node_modules

twitter-bootstrap - ngx-bootstrap:模态打开时小而不是大