2016-06-28 2 views
0

pollyfills.js와 같은 일부 일반 ES5 파일과 함께 외부 commonjs 모듈 (react, react-dom)을 묶으려고합니다.꿀풀을 사용하여 외부 종속성을 묶는 방법

나는 그러나 나는 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

나는이 같은 파이프를 결합 할 수 있었다
관련 문제