gpt4 book ai didi

gulp - 如何使用 gulp 任务排除包含文件的目录

转载 作者:行者123 更新时间:2023-12-01 22:51:53 27 4
gpt4 key购买 nike

如何使用 gulp 清除所有目录和文件除了自定义脚本目录和该目录中的所有 js 文件?

  "devDependencies": {
"gulp": "^3.9.0",
"gulp-bower": "0.0.10",
"rimraf": "2.2.8",
"gulp-concat": "2.5.2",
"gulp-uglify": "1.2.0",
"gulp-connect": "2.2.0",
"gulp-clean": "0.3.1"
}

此任务删除自定义脚本文件夹中的文件

gulp.task('clean', function () {
return gulp.src(['./Scripts/lib', '!./Scripts/lib/custom-scripts', '!./Scripts/lib/custom-scripts/*.js'], { read: false })
.pipe(clean());
})

最佳答案

gulp-rimrafgulp-ignore 替换 clean() 解决了这个问题。

  "devDependencies": {
"gulp": "^3.9.0",
"gulp-bower": "0.0.10",
//"rimraf": "2.2.8",
"gulp-concat": "2.5.2",
"gulp-uglify": "1.2.0",
"gulp-clean": "0.3.1",
"gulp-ignore": "^2.0.1",
"gulp-rimraf": "^0.2.0"
}



var gulp = require("gulp");
var rimraf = require("gulp-rimraf");
var bower = require('gulp-bower');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var ignore = require('gulp-ignore');


gulp.task('clean', function () {
return gulp.src('./Scripts/lib', { read: false })
.pipe(ignore('./Scripts/lib/custom-scripts/**'))
.pipe(rimraf());
});

关于gulp - 如何使用 gulp 任务排除包含文件的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33256792/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com