0

I'm trying to copy all my assets into my public dir but I want all assets except JavaScript and CSS files cause they are concatenated and minified into prod.min.js and prod.min.css so I want to make two exception for min.js and min.css files.

I have tried this (only for JS for now)

gulp.src([src + '/**/*', src + '/**/*.min.js', '!' + src + '/**/*.js'])
          .pipe(gulp.dest(dest))

But it results in no JavaScript files at all.

How can do this?

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63
jaumard
  • 8,202
  • 3
  • 40
  • 63
  • Maybe you can find answer on your question here - http://stackoverflow.com/questions/23384239/excluding-files-directories-from-gulp-task – lutien Feb 26 '16 at 20:39
  • Thanks ! I see this answer but I want the exact opposite :D but can't manage how do it :( – jaumard Feb 27 '16 at 14:06

2 Answers2

0

Create separate glob arrays for CSS and JS. Then you can be more selective in which get moved.

Adrian Lynch
  • 8,237
  • 2
  • 32
  • 40
  • I can separate into 2 glob but my question will be the same, I want to exclude all js (or css) files except .min.js (or .min.css) – jaumard Feb 25 '16 at 16:41
  • Isn't it a case of just having `'/**/*.min.js'` – Adrian Lynch Feb 25 '16 at 16:46
  • no cause I want to copy all other assets like images, fonts... just want to know if there a way to do it in one task instead of 2 or 3 – jaumard Feb 25 '16 at 20:37
0

I am also dealing with this problem at the moment.

The way I patched it (it's a patch because it's not really an optimal solution) is by making two passes:

  1. First pass -> move all (**/*.*) files and negate all js extensions (!**/*.js)
  2. Second pass -> move only the minified files (**/*.min.js)

A quick task example:

gulp.task('move-min-not-src', [], function() {

    var paths = [
        [
            'source-folder/**/*.*',
            '!source-folder/**/*.js'
        ],
        [
            'source-folder/**/*.min.js'
        ]
    ];

    paths.forEach(function(path) {

        gulp.src(path)
            .pipe(
                gulp.dest('destination-folder/')
            );

    });

});