[requirejs] Excluding files/directories from Gulp task

I have a gulp rjs task that concatenates and uglifies all my custom .JS files (any non vendor libraries).

What i am trying to do, is exclude some files/directories from this task (controllers and directives).

Heres my tree:

 - application
    - resources
      - js
        main.js
        - vendor
            - jquery
            - modernzr
            - angular
        - controllers
            - controller1
            - controller2
            - controller3
        - directives
            - directives1
            - directives2
            - directives3
        - widgets
            - widget1
            - widget2
            - widget3
            - widget4
        - modules
            - modules1
            - modules2
            - modules3
            - modules4

Here my gulp.js

dir = {
    app:        'application',
    dest:       'dest',
};

config = {
    src: {
        js: dir.app + '/resources/js'
    },
    dest: {
        js: dir.dest + '/resources/js'
    }
};

gulp.task('rjs', function() {

      rjs({
            baseUrl: config.src.js,
            out: 'main.js',
            name: 'main',
            mainConfigFile: config.src.js + '/main.js',
            exclude: [ 'jquery', 'angular']         
        })
        .pipe(prod ? uglify({ mangle: false, outSourceMap: true, compress: { drop_console: true } }) : gutil.noop())
        .pipe(gulp.dest(config.dest.js))
        .pipe(filesize())
        .pipe(dev ? connect.reload() : gutil.noop());

});

This question is related to requirejs gulp minify uglifyjs

The answer is


Gulp uses micromatch under the hood for matching globs, so if you want to exclude any of the .min.js files, you can achieve the same by using an extended globbing feature like this:

src("'js/**/!(*.min).js")

Basically what it says is: grab everything at any level inside of js that doesn't end with *.min.js


Examples related to requirejs

Excluding files/directories from Gulp task Dynamic require in RequireJS, getting "Module name has not been loaded yet for context" error? Relation between CommonJS, AMD and RequireJS? Mismatched anonymous define() module Does it make sense to use Require.js with Angular.js? Prevent RequireJS from Caching Required Scripts

Examples related to gulp

How to fix ReferenceError: primordials is not defined in node Everytime I run gulp anything, I get a assertion error. - Task function must be specified Stylesheet not loaded because of MIME-type Node update a specific package 'gulp' is not recognized as an internal or external command How to watch and reload ts-node when TypeScript files change How to use npm with ASP.NET Core Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style Gulp error: The following tasks did not complete: Did you forget to signal async completion? NPM vs. Bower vs. Browserify vs. Gulp vs. Grunt vs. Webpack

Examples related to minify

Excluding files/directories from Gulp task How to concatenate and minify multiple CSS and JavaScript files with Grunt.js (0.3.x) Uncaught TypeError: undefined is not a function on loading jquery-min.js sass --watch with automatic minify? How to minify php page html output? Is there a good JavaScript minifier? What's the difference between jquery.js and jquery.min.js? Tool to Unminify / Decompress JavaScript

Examples related to uglifyjs

Excluding files/directories from Gulp task