我初學者使用一飲而盡,我試圖用一口青菜和一口手錶編譯我SASS文件,但運行一飲而盡手錶命令一飲而盡腕錶無法編譯SASS爲CSS
後創建任何CSS文件gulpfile.js
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var watch = require('gulp-watch');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
//gulp.task('default', function() {
// // place code for your default task here
//});
gulp.task('default', ['sass', 'watch']);
gulp.task('sass', function() {
return gulp.src('./sass/*.scss')
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
gulp.task('sass', function() {
return gulp.src('./sass/*.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./css'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('./sass/*.scss', ['sass']);
});
項目hiererchy
myProject
|_ public_html
| |_ css
| |_ sass
| |_ js
| |_ index.html
|_ node_modules
|_ gulpfile.js
|_ package.json
當我run gulp
[21:37:26] Starting 'sass'...
[21:37:26] Starting 'watch'...
[21:37:26] Finished 'watch' after 7.01 ms
[21:37:26] Finished 'sass' after 29 ms
[21:37:26] Starting 'default'...
[21:37:26] Finished 'default' after 7.11 ?s