I have what I think is a standard .angular-cli.json file. In apps[0] it has:
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
],
The above works fine with an "ng build" or an "ng serve". However, if I do an "ng build --prod" these two css files are ignored. The way I am getting around this is by using a CDN version of bootstrap.min.css and adding styles.css to a publicly available resource (Azure blog storage) and then referencing them from index.html.
FWIW, if I do an "ng serve --prod" it still works in my localhost/dev environment. But "ng build --prod" does not.
Any ideas where to start?
With the help of Angular CLI, you can install CSS or SCSS on your project and start working on that in a suitable way. If you are working with the CSS or SCSS in your angular project then it is very easy for you as compared to most other frameworks.
you have this problem because of the order of css file when bundling them, the only possible solution now is to let only style.css file like this:
"styles": [
"styles.css"
],
and import bootstrap.min.css inside your style.css
@import url("../node_modules/bootstrap/dist/css/bootstrap.min.css");
that willmake your app work in local and prod, the alternative solution is build with --extract-css=false
ng build --prod --extract-css=false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With