4

We upgraded angular version from 11 to 12 and the stylings are not applied in production build.

If I run the application in dev build I dont see the styling issues but this occurs only when we do the prod build.

I see in angular 12 ng build --prod is deprecated so used new command recommended by Angular ng build --configuration production. Adding the screen shot below: [Package.json showing the version difference][1] [Package.json showing the version difference][2]

When I inspect the styles, the custom style we applied in respective component.scss are not applied.

So am I missing some configuration?

Below is the 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.sstatic.net/zBq0B.png [2]: https://i.sstatic.net/2cy0W.png

1
  • so you mean the css was modified by the build process? Commented Jun 17, 2021 at 8:26

1 Answer 1

2

This seems to be still an open issue with angular that still exists:

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

you could try doing a possible workaround:

ng build --prod -extract-css false
Sign up to request clarification or add additional context in comments.

3 Comments

I am facing the issue again when I upgraded to Angular 13. Any possible solutions from you? I tried to use -extract-css false but its deprecated.
@MaheshDharwad try to use styleUrlss:['style.css'] instead of styles in your angular components. otherwise try adding this in front of your css-classes :host ::ng-deep .yourCssClass { }
@Devis Jahn I use SCSS and in component used style urls styleUrls: ['./app.component.scss'] but no luck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.