简体   繁体   中英

How to make gulp work with files without extension

I want to make gulp work with files without extension also. I tried to do it the following ways:

    function someTask() {
        return gulp.src('./src/**/*.{html,,xml,txt}')
            .pipe(gulp.dest('./build'));
    }
    function someTask() {
        return gulp.src('./src/**/*.{html,!*,xml,txt}')
            .pipe(gulp.dest('./build'));
    }
    function someTask() {
        return gulp.src('./src/**/*.{html,[^*],xml,txt}')
            .pipe(gulp.dest('./build'));
    }

but I haven't got any results. Any suggestions?

I am still trying to find a better answer, but one route is to get all the files and then eliminate the extentions you don't want. Like

var debug = require('gulp-debug');  // nice, will list all the files in the stream

return gulp.src(['./src/**/*', '!./src/**/*.{js,png}'])
    .pipe(debug())
    .pipe(gulp.dest('./build'));

So here {js,png} list the possible file extensions in your src directories you don't want.

Hopefully there is a better answer.

[EDIT]: Maybe there is, try this:

return gulp.src(['./src/**/*.{html,xml,txt}', './src/**/!(*\.*)'])

This part ./src/**/!(*\\.*) appears to match only files with no . in them, ie, no extention.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM