javascript - Gulp - 如何附加到目标而不是替换

标签 javascript angularjs node.js gruntjs gulp

我有这样的代码:

gulp.task('concat-uglify-js', function() {
  return gulp.src(src + 'js/*.js')
    .pipe(concat('angular-filemanager.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest(dst))
});

gulp.task('cache-templates', function () {
  return gulp.src(tplPath + '/*.html')
    .pipe(templateCache('cached-templates.js', {
      module: 'FileManagerApp',
      base: function(file) {
        return tplPath + '/' + path.basename(file.history);
      }
    }))
    .pipe(uglify())
    .pipe(gulp.dest(dst));
});

我想将这两个任务输出合并到一个文件中......“angular-filemanager.min.js”

有一个选项可以做类似的事情

.pipe(gulp.dest(dst, {mode: "APPEND_INSTEAD_OF_REPLACE"}));

?

谢谢!

最佳答案

我还没有对此进行测试,但请尝试使用 gulp-filter :

var gulpFilter = require('gulp-filter');

gulp.task('concat-uglify-js', function() {

  var filter = {
    html: gulpFilter('*.html'),
    js  : gulpFilter('*.js')
  };

  return gulp
    .src([src + 'js/*.js', tplPath + '/*.html'])
    .pipe(filter.html)
    .pipe(templateCache('cached-templates.js', {
      module: 'FileManagerApp',
      base: function(file) {

        return tplPath + '/' + path.basename(file.history);
      }
    }))
    .pipe(filter.html.restore)
    .pipe(filter.js)
    .pipe(concat('angular-filemanager.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest(dst));
});

关于javascript - Gulp - 如何附加到目标而不是替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31877493/

相关文章:

javascript - 当 ul-li 切换时,数据表会发生变化

c# - 这可以通过 javascript 实现吗?

php - 通过php获取html5上传的有值(value)的图片

angularjs - parseFloat 在 angularjs View 中不起作用

django - Angular NgRessource 具有来自 django Rest 框架的分页结果

javascript - Node 表达带有排除项的虚荣 url 路径参数

javascript - 函数的括号包裹 - (function() { }) () 和 `.call()`

javascript - Angularjs 变量不会改变

ios - react native - 在构建发布时将 --max_old_space_size 添加到 iOS 项目

javascript - Node Js 和 Google Geocode API