Ian Hazzard
Ian Hazzard

Reputation: 7771

How to generate minified css from Angular (2+)

I built an angular project in SASS, but I need to be able to use the project's styles in codepen demos. I was thinking that I need to somehow generate minified CSS in the "dist" folder so I can use it as an external source in codepen. The styles are constantly updated in the Angular project, so I'm looking for a solution that automatically generates the CSS file everytime I run the build command.

I'm not sure how to set this up or what to search for. Any ideas?

Upvotes: 0

Views: 380

Answers (1)

kacase
kacase

Reputation: 2869

By default angular binds the styles directly to the directives which means they are part of the generated javascript, not the css.

You can use the node-sass cli: https://github.com/sass/node-sass

install it with

npm i -g node-sass

and use it to convert your sass/scss files

node-sass src/style.scss dest/style.css

Upvotes: 1

Related Questions