[Node pkg]: Install sass with npm

Node.js

12/05/2019


Initialize npm in project directory

TEXT
npm init -y

-y flag skips the prompts

Install sass with npm

In the project directory,

TEXT
npm i node-sass

scripts in package.json

Modify scripts in package.json file

JSON
{
// ...
"scripts": {
"sass": "node-sass -w scss/ -o src/css --recursive"
}
}

Make sure to have scss files in scss folder under project root, and locate source files under src folder.

npm run

TEXT
npm run sass

This will create a compiled css file at ./src/css/main.css

+)

When using git, create .gitignore to ignore node_modules folder


WRITTEN BY

Keeping a record