Minify CSS with Node-sass

Matt Leach picture Matt Leach · Nov 13, 2016 · Viewed 27.9k times · Source

I'm using SCSS in my NodeJS project and have my script working to turn all my seperate SCSS files into a single CSS file using the following command

node-sass -w public/css/scss/style.scss public/css/style.css

My only issue is that I also want the CSS file to be minified. Is this possible with Node-sass? The docs say there is an option for 'compact' but it doesn't seem to work when I try

node-sass -w compact public/css/scss/style.scss public/css/style.css

Thank you in advance for any help.

Answer

vretamal picture vretamal · Nov 14, 2016

In the node-sass documentation says you have to use --output-style, and it could be nested | expanded | compact | compressed. To minify use compressed

For example:

node-sass -w public/css/scss/style.scss public/css/style.css --output-style compressed

will minify the CSS.