0

I am using bower and wiredep. I want to have a gulp task to combine and uglify all files into a single file... "allmyjs.min.js"

My problem is with libraries like "angular" where within the bower_components/angular directory, there are multiple js files:

angular.js
angular.min.js
index.js

All I want to pick up is the non-minified file so I can concat all my js and minify them, but how do I specify a rule in my list of files that can ignore the .min files?

Right now I have rules like:

"myjs/js/*.js"
"bower_components/angular/angular.js" <- this works, but I have to list out every single dependency which is a nightmare
//"bower_components/angular/*.js" <- this does not work because it picks up everything

I know when I do a wiredep, it looks like bower is smart enough to pick out the specific "JS" files that it injects into my HTML. Is there a way that I can do something in my gulpfile that is smart enough to read the dependencies in bower and include the correct/associated js files without me having to list out every single dependency: (e.g. "bower_comonents/angular/angular.js") for every single bower dependency?

Rolando
  • 58,640
  • 98
  • 266
  • 407

1 Answers1

1

In gulp.src a glob that begins with '!' excludes matching files from the glob results up to that point

var jsFiles = './js/**/*.js';
var minJsFiles = './js/**/*.min.js';

gulp.task('minify', function(){
    return gulp.src([jsFiles, '!' + minJsFiles])
    .pipe(doSomething()); // min files or some other stuff here
});
Maciej Wojsław
  • 403
  • 2
  • 10