4

我们将 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

4

1 回答 1

2

这似乎仍然是仍然存在的角度问题:

https://github.com/angular/angular-cli/issues/9475

您可以尝试做一个可能的解决方法:

ng build --prod -extract-css false
于 2021-06-17T08:30:22.637 回答