使用gulp watch
,我得到sass编译器模块的错误如下:
[01:41:22] Using gulpfile D:\Workspace\WebDev\agaweed\public_html\wp-content\themes\master\gulpfile.js
[01:41:22] Starting 'watch'...
[01:41:23] Finished 'watch' after 26 ms
[01:41:35] Starting 'styles'...
[01:41:35] 'sass' is not recognized as an internal or external command,
operable program or batch file.
events.js:160
throw er; // Unhandled 'error' event
^
Error: Gem undefined is not installed.
我在gulpfile.js
中加载了gulp-ruby-sass,并将watch
任务添加为:
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload'),
del = require('del');
...
// Watch
gulp.task('watch', function() {
// Watch .scss files
gulp.watch('src/styles/**/*.scss', ['styles']);
// Watch .js files
gulp.watch('src/scripts/**/*.js', ['scripts']);
// Watch image files
gulp.watch('src/images/**/*', ['images']);
// Create LiveReload server
livereload.listen();
// Watch any files in dist/, reload on change
gulp.watch(['dist/**']).on('change', livereload.changed);
});
非常感谢任何有关问题的帮助:)
答案 0 :(得分:0)
你是否安装了类似'gulp-sass'的东西,你的gulp文件中还需要初始化它。
var sass = require('gulp-sass');
然后加入你的任务
gulp.task('sass', function () {
return gulp.src('./sass/**/*.scss')
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest('./css'));
});