0

Here is what I have so far:

gulp.task('build', function () {
// Concat all JS files into a single one called app.min.js
gulp.src([
        'public_html/js/app/' + argv.project + '.js',  // Take project specific file
        '!public_html/js/app/*.js',                 // Do not take all files from app folder
        'public_html/js/**/*.js',                   // Take all JS files that hasn't been excluded
    ])
    .pipe(concat('app.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('dist/' + argv.project + '/'));
});

The goal is to:

  • Take one specific file from app folder
  • Make sure to exclude all the others, no matter how many files are in the app folder.
  • Take all JS files inside js folder, but without taking the already excluded folder app

The Problem

is that when I define '!public_html/js/app/*.js', the specific file specified BEFORE doesn't get added to the result at all. If I remove the exclusion of app folder, every file within the app folder gets added to the result, making configuration changes override each other.

The firewall reasoning of loading the specific file before excluding the whole folder did not work. Is this at all possible?

Thanks in advance.


Solution

gulp.src([
    // Do not take all files from app folder except the project file
    '!public_html/js/app/{(*.js),!(' + argv.project + '.js)}',

    // Take all JS files that hasn't been excluded
    'public_html/js/**/*.js',                   
    ])
Marco Aurélio Deleu
  • 4,279
  • 4
  • 35
  • 63

0 Answers0