2016-06-28 5 views
0

私は、外部commonjsモジュール(react、react-dom)を、pollyfills.jsのようないくつかのプレーンなES5ファイルとともにバンドルしようとしています。gulpを使って外部依存関係を束ねる方法

私は、しかし、私はそれらをtoggether置くのに苦労、browserify.require

var externalBundler = browserify(); 
config.externalModules.forEach(externalBundler.bundle); 
return externalBundler.bundle() 
    .pipe(source("external.js")) 
    .pipe(buffer()) 
    .pipe(sourcemaps.init({ debug: true, loadMaps: true })) 
    .pipe(uglify()) 
    .on('error', gutil.log) 
    .pipe(sourcemaps.write('./')) 
    .pipe(gulp.dest('./dist/')); 

とgulp.concatを使用して他のスクリプトを使用して外部モジュールをバンドルすることができます。

gulp.task('bundle-externalscripts', function() { 
    var externalBundler = browserify({ debug: true }); 
    for (var module of config.externalModules) externalBundler.require(module); 

    var globalScripts = gulp.src(paths.scripts); 

    var externalModules = externalBundler.bundle() 
    .pipe(source("externalmodules.js")) //always convert to vinyl source stream 
    .pipe(buffer());    //in buffered mode 

    return merge(globalScripts, externalModules) 
    .pipe(sourcemaps.init({ debug: true, loadMaps: true })) 
    .pipe(concat("external.js")) 
    .pipe(uglify()) 
    .pipe(sourcemaps.write('./')) 
    .pipe(gulp.dest('./dist/')); 
}); 

答えて

0

は、私はこのようなパイプを組み合わせることができました
関連する問題