Gurpreet Bhopal
Gurpreet Bhopal

Reputation: 73

Angular Material 2 theme not working in production

I have imported the theme CSS to my style.css in my project as below, just like how it was stated on the Angular Material website.

@import '~@angular/material/prebuilt-themes/indigo-pink.css';

When I have it in dev mode, the styling works, however, when I build to production, the styling does not work.

Any ideas?

Upvotes: 4

Views: 2115

Answers (2)

Elvin Garibzade
Elvin Garibzade

Reputation: 495

Add this line into the styles array in angular-cli.json :

"../node_modules/@angular/material/prebuilt-themes/indigo-pink.css"

Upvotes: 3

Tng
Tng

Reputation: 614

you can add <link href="https://unpkg.com/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet">

in <head> section of index.html

OR copy the folder prebuilt-themes from node-modules/@angular/material e.g. to your /assets folder, then @import "./assets/prebuilt-themes/indigo-pink.css"; in your css/scss file

Upvotes: 1

Related Questions