如何保存流到Gulp.js多个目的地吗?

Konstantin Tarkus提出了一个问题:How to save a stream into multiple destinations with Gulp.js?,或许与您遇到的问题类似。

回答者Contra给出了该问题的处理方式:

Currently you have to use two streams for each dest when using file.contents as a stream. This will probably be fixed in the future.

var gulp       = require('gulp');
var rename     = require('gulp-rename');
var streamify  = require('gulp-streamify');
var uglify     = require('gulp-uglify');
var source     = require('vinyl-source-stream');
var browserify = require('browserify');
var es         = require('event-stream');

gulp.task('scripts', function () {
    var normal = browserify('./src/index.js').bundle()
        .pipe(source('bundle.js'))
        .pipe(gulp.dest('./dist'));

    var min = browserify('./src/index.js').bundle()
        .pipe(rename('bundle.min.js'))
        .pipe(streamify(uglify())
        .pipe(gulp.dest('./dist'));

    return es.concat(normal, min);
});

EDIT: This bug is now fixed in gulp. The code in your original post should work fine.

希望本文对你有帮助,欢迎支持JavaScript中文网

原文链接:stackoverflow.com

上一篇:custom-guider
下一篇:数据结构库

相关推荐

公众号

欢迎 JavaScript 爱好者