本文介绍了gulp - 排除文件无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的大文件中,我有一个任务,它将所有内容写入 dist 文件夹。现在我正在尝试编写另一个任务,清除 dist 除供应商包之外中的所有内容。这是我到目前为止:

  gulp.task('clean',function(){
return gulp .src(['./ dist','!./ dist / scripts / vendor.js'])
.pipe($。clean());
});

当我运行它时,它会一并删除 dist 。什么是排除一个文件的正确方法?



注意:我也尝试使用 gulp-ignore gulp-filter 具有相同的结果。 这个Github问题让我朝着正确的方向前进。我想要的模式是

['dist / *,'!dist / scripts {,/ vendor.js}']

如果有人知道任何有用的文档,那么这些文档将会非常有用:)


In my gulpfile I have a task which builds and writes everything to a dist folder. Now I'm trying to write another task that cleans out everything in dist except for my vendor bundle. This is what I have so far:

gulp.task('clean', function () {
    return gulp.src(['./dist', '!./dist/scripts/vendor.js'])
        .pipe($.clean());
});

When I run this it deletes dist altogether. What's the right way to exclude just one file?

Note: I've also tried using gulp-ignore and gulp-filter with the same results.

解决方案

This Github issue led me in the right direction. The pattern I wanted was

['dist/*, '!dist/scripts{,/vendor.js}'].

If anyone knows of any good globbing docs that would be super helpful :)

这篇关于gulp - 排除文件无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 11:38