Summary: Node Express or node project, to automatically compile sass methods, such as gulp, such as koalas, such as today I want to say this package node-compass.
- Method One: Command-line compilation sass:
- Method Two: Gulp-sass
- Method Three: Node-compass
Method One: Command-line compilation sass:
1 Compass Compile
Enter confirmation to generate the corresponding CSS code
Method Two: Gulp-sass
1. Prerequisites:
The computer has Ruby installed,
The project has been installed with the configuration of the basic gulp (configuration and installation is not covered in this article.) Gulp basic usage also not introduced)
2. Download the Gulp-sass package:
NPM Install Gulp-sass--save-dev
3. Basic usage:
Add the following code to your gulpfile.js:
1 varGulp = require (' Gulp '));2 varSass = require (' Gulp-sass '));3 4Gulp.task ("Sass",function() {5 returnGULP.SRC ("Test/*.scss")6. Pipe (Sass (). On ("Error", Sass.logerror))7. Pipe (Gulp.dest ("Public/css"));8 });9 TenGulp.task (' Watch ',function () { OneGulp.watch ("Public/sass/*.scss", ["Sass"]); A});
Explanation: The first two sentences into the module, there is nothing to say it.
The 5th sentence: gulp.src () The parameters for your sass file, such as "Test/a.scss"--the automatic compilation of the test folder under the A.scss. If you need to compile all the Scss files under the folder, use * to indicate: Test/*.scss.
6th sentence: Write
If you have used gulp or koalas to automatically compile sass, then you must know: When you finish writing a sass, the basic is that the corresponding CSS code will be generated at the same time. But Node-compass not, you have to be on the web.
Nodejs compiling SASS Module Package Node-compass, and Gulp package Gulp-sass use method