1

I am trying to style non readonly text areas. Although it's working fine locally with ng serve, the class is not being applied at all when deploying with ng build --prod.

This is the CSS code:

.my-class:not(:read-only) {
    ...;
}

With ng serve, the browser dev console displays the following css:

.my-class[_ngcontent-c11]:not(:-moz-read-only) { 
    ...;
}

.my-class[_ngcontent-c11]:not(:read-only) { 
    ...;
}

However, when I use ng build --prod, the CSS I get is

.my-class:not(:-moz-read-only),
.my-class:not(:read-only) { 
    ...;
}

Unfortunately, the last version is simply not working. The style is not applied to the element. If I use Chrome's override feature and remove the .my-class:not(:-moz-read-only), line completely, it works fine.

Why is the code different from ng serve to ng build --prod, why isn't the style being applied, and what can I do to fix it?

The angular version (project and CLI) I am using is 10.2.0 and I am using SCSS.

3
  • 1
    To whoever voted to close the question because it "doesn’t meet a Stack Overflow guideline", can you please explain what guideline this question does not meet? When someone is sentenced to death, they are usually given the reason for the death penalty, as in the crime they committed, or the law they violated. Is it too much to expect the same on stackoverflow? Commented Feb 14, 2022 at 14:53
  • Ideally it should work. which version of angular are you using? Commented Feb 14, 2022 at 15:11
  • Hello Vimal. Thanks for reading. I've edited the version at the end of the question. Commented Feb 14, 2022 at 15:37

0

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.