我们将angular版本从11升级到12,并且在生产版本中没有应用样式。
如果我在dev build中运行应用程序,我看不到样式问题,但这只在我们进行prod build时发生。
我看到在angular 12中ng build --prod被弃用了,所以Angular ng build --configuration production推荐使用新的命令。添加下面的屏幕截图:显示版本差异的Package.json显示版本差异的Package.json
当我检查样式时,我们在各自component.scss中应用的自定义样式没有应用。
那么我是不是遗漏了一些配置?
下面是tsconfig.json -
{
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"target": "es2015",
"downlevelIteration": true,
"declaration": false,
"importHelpers": true,
"lib": [
"es2018",
"dom"
],
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"removeComments": false,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"node_modules/@types"
],
"watch": false
},
"exclude": [
"node_modules"
],
"angularCompilerOptions": {
"strictInjectionParameters": true
}
}
` 1:https://i.stack.imgur.com/zBq0B.png 2:https://i.stack.imgur.com/2cy0W.png
发布于 2021-06-17 16:30:23
这似乎仍然是一个仍然存在的关于angular的问题:
https://github.com/angular/angular-cli/issues/9475
您可以尝试执行一种可能的解决方法:
ng build --prod -extract-css falsehttps://stackoverflow.com/questions/68015362
复制相似问题