我編輯「_globals.scss」時,我的Gulpfile.js不工作,甚至沒有創建css文件夾,也不會自動添加文件。這段代碼也沒有任何寶頂變化時,我創建了這個文件就像在「_globals.scss」體色變化的變化也沒有工作,幫助我如何在窗口中使用CMDGulpfile.js文件不能正常工作?
var gulp = require('gulp');
var livereload = require('gulp-livereload')
var uglify = require('gulp-uglifyjs');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
gulp.task('imagemin', function() {
return gulp.src('./themes/custom/shinedelhi/images/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('./themes/custom/shinedelhi/images'));
});
gulp.task('sass', function() {
gulp.src('./themes/custom/shinedelhi/sass/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 7', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./themes/custom/shinedelhi/css'));
});
gulp.task('uglify', function() {
gulp.src('./themes/custom/shinedelhi/lib/*.js')
.pipe(uglify('main.js'))
.pipe(gulp.dest('./themes/custom/shinedelhi/js'))
});
gulp.task('watch', function(){
livereload.listen();
gulp.watch('./themes/custom/shinedelhi/sass/**/*.scss', ['sass']);
gulp.watch('./themes/custom/shinedelhi/lib/*.js', ['uglify']);
gulp.watch(['./themes/custom/shinedelhi/css/style.css', './themes/custom/shinedelhi/**/*.twig', './themes/custom/shinedelhi/js/*.js'], function (files){
livereload.changed(files)
});
});
你是如何調用gulpfile? 「吞噬」還是「吞食」?後者應該工作,AFAIK。前者需要一個調用「監視」任務的「默認」任務。 – Sergeon