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/sebastian/images/*')
.pipe(imagemin({
progressive: true,svgoPlugins: [{ removeViewBox: false }],use: [pngquant()]
}))
.pipe(gulp.dest('./themes/custom/sebastian/images'));
});
gulp.task('sass',function() {
return gulp.src('./themes/custom/sebastian/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/sebastian/css'));
});
gulp.task('uglify',function() {
return gulp.src('./themes/custom/sebastian/lib/*.js')
.pipe(uglify('main.js'))
.pipe(gulp.dest('./themes/custom/sebastian/js'));
});
gulp.task('watch',function() {
livereload.listen();
gulp.watch('./themes/custom/sebastian/sass/**/*.scss',gulp.series('sass'));
gulp.watch('./themes/custom/sebastian/lib/*.js',gulp.series('uglify'));
gulp.watch(
[
'./themes/custom/sebastian/css/style.css','./themes/custom/sebastian/**/*.twig','./themes/custom/sebastian/js/*.js'
],function(files) {
livereload.changed(files);
}
);
});
[18:40:58]使用gulpfile C:\ xampp \ htdocs \ drupal-8.7.9 \ drupal-8.7.9 \ themes \ custom \ sebastian \ gulpfile.js
[18:40:58]开始“观看” ...
为什么不完成手表?
Gulp watch不会在sebastian文件夹中创建一个css文件夹。