如何告诉Gulp在gulp.src([…])中跳过或忽略某些文件?例如,我不想在我的css /文件夹 – “css / ignnore.css”中压缩并连接这个文件?
var autoprefix = require('gulp-autoprefixer'),concat = require('gulp-concat'),minifyCss = require('gulp-minify-css'); gulp.task('styles',function() { gulp.src([ 'css/ignnore.css',// ignore this file 'css/*.css' ]) .pipe(concat('styles.css')) .pipe(autoprefix('last 2 versions')) .pipe(minifyCss()) .pipe(gulp.dest('local/view/style/base/css/dist/')); });
解决方法
添加!
gulp.task('styles',function() { gulp.src([ '!css/ignnore.css',// <== ! 'css/*.css' ]) .pipe(concat('styles.css')) .pipe(autoprefix('last 2 versions')) .pipe(minifyCss()) .pipe(gulp.dest('local/view/style/base/css/dist/')); });