
1. Khởi tạo package.json,
Sau đó điền các thông tin của project trong màn hình terminal
npm init

2. Cài đặt node sass
Để tải trình biên dịch, chúng ta sẽ cài đặt gói node-sass.
npm i node-sass
Tiếp theo
3. Thêm một tập lệnh trong package.json trong scripts
"scss-build": "node-sass --watch folder-parent/scss/style.scss folder-parent/css/style.css --output-style compressed"
Về đường dẫn folder thì bạn tùy chỉnh theo project của mình nhé.
Giống như vậy trong package.json
{
“name”: “example-project”,
“version”: “0.4.2”,
“scripts”: {
“start”: “node ./bin/www”,
"scss-build": "node-sass --watch folder-parent/scss/style.scss folder-parent/css/style.css --output-style compressed"
},
"dependencies": {
"express": "~4.16.0",
"express-favicon": "^2.0.1",
}
}
Quá trình cài đặt đã xong, tiếp theo là compile
npm run scss-build
Khi build xong, nếu không báo lỗi thì bạn đã cài đặt đúng
Bây giờ hãy làm việc, nó sẽ tự build khi bạn save

Xem thêm: