从Gulp任务中排除文件/目录 - Excluding files/directories from Gulp task

10/14 03:33
阅读数 0

问题:

I have a gulp rjs task that concatenates and uglifies all my custom .JS files (any non vendor libraries). 我有一个gulp rjs任务,它将我的所有自定义.JS文件(所有非供应商库)串联并丑化。

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 这是我的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());

});

解决方案:

参考一: https://en.stackoom.com/question/1a7J9
参考二: https://stackoom.com/question/1a7J9
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部