/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/