【问题标题】:Gulp exclude folder containg an underscore ('_')Gulp 排除包含下划线('_')的文件夹
【发布时间】:2016-01-19 23:55:28
【问题描述】:

是否可以排除包含下划线的文件夹?

我试过了:

gulp.task( 'updateLayout', function () {
    return gulp.src( [targetPath + '/layout/**/*.ai', '!'+targetPath+'/layout/_**/'] )
        .pipe( gulp.dest( 'layout' ) );
} )

但它不起作用

【问题讨论】:

    标签: gulp filepath src taskmanager


    【解决方案1】:

    对于排除 glob 模式,您只需在末尾添加 *.*。所以这意味着排除任何以 _ 开头的文件夹中的任何文件

    gulp.task( 'updateLayout', function () {
        return gulp.src( [targetPath + '/layout/**/*.ai', '!'+targetPath+'/layout/_**/*.*'] )
            .pipe( gulp.dest( 'layout' ) );
    } )
    

    【讨论】:

    • 我不确定是否发生了变化,但在我的情况下,它的工作方式如下:gulp 不会复制文件夹“*_”中的图像,但会复制文件夹(为空)。
    • 我知道这已经很晚了,但是在 src 中添加 , { nodir: true } 作为最后一个参数将省略空目录。
    猜你喜欢
    • 1970-01-01
    • 2013-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-28
    • 2019-03-06
    • 2018-04-10
    • 1970-01-01
    相关资源
    最近更新 更多