我想缩小并重命名文件夹中的所有.css(../dist/css),但它说有错误(您可以在下面的屏幕截图中看到错误)。
var gulp = require('gulp');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var lost = require('lost');
var rucksack = require('rucksack-css');
var cssnano = require('cssnano'); var rename = require('gulp-rename');
gulp.task('css', function() {
var plugins = [
autoprefixer({
browsers: ['last 2 version']
}),
rucksack({
quantityQueries: false,
alias: false,
easings: false,
inputPseudo: false
}),
lost
];
return gulp.src('app/styles/**/*.css')
.pipe(postcss(plugins))
.pipe(gulp.dest('dist/css'));
});
// ========这部分不起作用============
gulp.task('css-min', ['css'], function() { return gulp.src('app/styles/*.css') .pipe(cssnano()) .pipe(rename({suffix: '.min'})) .pipe(gulp.dest('dist/css')); });
gulp.task('watch', ['css', 'css-min'], function() {
gulp.watch('app/styles/**/*.css', ['css']);
});
gulp.task('default', ['watch']);