Angular 12 post-升级样式问题
Angular 12 post-upgrade styling issue
我们将 angular 版本从 11 升级到 12,并且样式未应用于生产构建。
如果我 运行 开发构建中的应用程序,我看不到样式问题,但这只会在我们进行产品构建时发生。
我在 angular 12 中看到 ng build --prod
已弃用,因此使用 Angular ng build --configuration production
推荐的新命令。
添加以下屏幕截图:
[Package.json 显示版本差异][1]
[Package.json 显示版本差异][2]
当我检查样式时,我们在相应 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
这似乎仍然是一个悬而未决的问题 angular 仍然存在:
https://github.com/angular/angular-cli/issues/9475
您可以尝试做一个可能的解决方法:
ng build --prod -extract-css false
我们将 angular 版本从 11 升级到 12,并且样式未应用于生产构建。
如果我 运行 开发构建中的应用程序,我看不到样式问题,但这只会在我们进行产品构建时发生。
我在 angular 12 中看到 ng build --prod
已弃用,因此使用 Angular ng build --configuration production
推荐的新命令。
添加以下屏幕截图:
[Package.json 显示版本差异][1]
[Package.json 显示版本差异][2]
当我检查样式时,我们在相应 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
这似乎仍然是一个悬而未决的问题 angular 仍然存在:
https://github.com/angular/angular-cli/issues/9475
您可以尝试做一个可能的解决方法:
ng build --prod -extract-css false