Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I exclude only .min.js files in gulp task, while staying in same directory?

I am trying to set up a build system for my front end work though I am running into a problem where it loops processing files over and over again. This is a problem with my js processing since I am not sure how to exclude just the files with .min as a suffix.

The task goes as follows

return gulp.src(["!dev/js/*.min.js", "dev/js/*.js"])
        .pipe(plumber())
        .pipe(browserify())
        .pipe(smaps.init())
            .pipe(uglyify({preserveComments: "license"}))
        .pipe(smaps.write())
        .pipe(rename({suffix: ".min"}))
        .pipe(gulp.dest(output_dir));

Though what I have found is that it still targets the .min.js files since they are also seen as .js files. I have messed around with a few different configurations of these wildcards but I keep ending up with the task looping creating example.min.js then example.min.min.js then example.min.min.min.js etc.

So, how can I just process files that do not include the .min prefix?

like image 434
sparcut Avatar asked Oct 02 '16 09:10

sparcut


2 Answers

You can use negated patterns to exclude .min.js files.

gulp.src(['dev/js/*.js', '!dev/js/*.min.js'])
like image 157
Himani Agrawal Avatar answered Nov 09 '22 22:11

Himani Agrawal


if you want to do it in only one string you can use:

gulp.src(["dev/js/!(*.min)*.js"])
like image 3
Aya Salama Avatar answered Nov 09 '22 23:11

Aya Salama