Alexander Vachenko
Alexander Vachenko

Reputation: 21

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?

Upvotes: 0

Views: 352

Answers (1)

Mark
Mark

Reputation: 181569

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, i.e., no extention.

Upvotes: 1

Related Questions