gulp从uglification中排除特定文件

时间:2015-01-29 09:32:56

标签: gulp gulp-concat gulp-uglify

我试图做以下事情。从可以是JS或COFFEE的文件数组中,编译coffee,uglify特定文件然后将它们全部连接起来。我不明白为什么我的过滤器没有在uglify周围工作。它似乎适用于咖啡,但使用uglify过滤器,它似乎并没有看到它,只是丑化所有文件。

var gulp = require('gulp');
var coffee = require('gulp-coffee');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');

var src = [
  'app/assets/1.js',
  'app/assets/2.js',
  'app/assets/components/1.coffee',
  'app/assets/components/2.js',
  'app/assets/utilities/*'
];


var coffeeSrcFilter = $.filter(['*.coffee']);
var minifyExclusionSrcFilter = $.filter(['*', '!app/assets/components/2.js']);


return gulp.src(paths.scripts)
  .pipe(sourcemaps.init())

      // coffee
      .pipe(coffeeSrcFilter)
        .pipe(coffee())
      .pipe(coffeeSrcFilter.restore())

      // uglify
      .pipe(minifyExclusionSrcFilter)
        .pipe(uglify())
      .pipe(minifyExclusionSrcFilter.restore())

      // concat
      .pipe(gulpConcat('out.js'))

  .pipe(gulp.dest('build/js'));
});

0 个答案:

没有答案