【发布时间】:2020-10-07 02:44:10
【问题描述】:
通常,当我构建简单的 SPA 时,我使用 --c 标志来选择适当的环境并将配置放入 angular.json 内 configurations dict,它住在 build dict 中,如下所示:
"build": {
"configurations": {
"staging": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging.ts"
}
],
"optimization": true,
"aot": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
}
当我使用命令npm run build:ssr 时,如何在适当的环境下运行 SSR 构建?
我尝试了相同的方案npm run build:ssr --c staging,但得到了错误Unknown option: 'staging'
【问题讨论】:
-
我认为您将 c 参数提供给 npm 而不是
build:ssr。你可以试试npm run build:ssr -- --c staging吗? stackoverflow.com/questions/43046885/…
标签: angular typescript server-side-rendering