Sass mit node-sass (Node.js)
Aus Wikizone
Version vom 3. Juli 2018, 21:40 Uhr von 37.49.33.174 (Diskussion) (Die Seite wurde neu angelegt: „== Links == https://webdesign.tutsplus.com/tutorials/watch-and-compile-sass-in-five-quick-steps--cms-28275 == Quickstart == === Installation === * Node.js mit…“)
Links
https://webdesign.tutsplus.com/tutorials/watch-and-compile-sass-in-five-quick-steps--cms-28275
Quickstart
Installation
- Node.js mit dem npm Paketmanager sollte installiert sein
- node-sass Installieren falls noch nicht vorhanden:
npm install node-sass
- Im Projektordner NPM Initialisieren (erstellt ein package.json File)
npm init
- Script Teil in package.json erweitern
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"scss": "node-sass --watch scss -o css"
}
node-sass: Refers to the node-sass package.
--watch: An optional flag which means “watch all .scss files in the scss/ folder and recompile them every time there’s a change.”
scss: The folder name where we put all our .scss files.
-o css: The output folder for our compiled CSS.
When we run this script it will watch every .scss file in the scss/ folder, then save the compiled css in css/ folder every time we change a .scss file.
5. Run the Script To execute our one-line script, we need to run the following command in the terminal:
npm run scss
And voila! We are watching and compiling SASS.