简体   繁体   English

带有browerify和gulp的多个捆

[英]multiple bundles with browerify and gulp

I can't find any examples using gulp and browerify in order to build multiple bundle. 我找不到使用gulp和browerify来构建多个捆绑包的任何示例。

I just want to do that with gulp. 我只想做那个与一饮而尽。

I found this repo but I how use it into a gulpfile. 我发现这个回购协议 ,但我如何使用它变成一个gulpfile。

I think this question didn't get much attention because browserify is misspelled as browerify . 我想是因为browserify拼错为browerify这个问题并没有得到太多的关注。

If you are still interested, here is an example gulpfile.js recipe to do exactly the same as the example in node-browserify docs 如果您仍然感兴趣,这里有一个示例gulpfile.js配方,其用法与node-browserify文档中示例完全相同

var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');

gulp.task('default', ['build-common', 'build-beep', 'build-boop']);

gulp.task('build-common', function () {
  var b = browserify()
    .require('./robot'); // same as -r option

  var stream = b.bundle()
    .pipe(source('common.js')) // the output filename
    .pipe(gulp.dest('./static/')); // the output directory
  return stream;
});

gulp.task('build-beep', function () {
  var b = browserify('./beep.js')
    .external('./robot.js'); // same as -e option

  var stream = b.bundle()
    .pipe(source('beep.js')) // the output filename
    .pipe(gulp.dest('./static/')); // the output directory
  return stream;
});

gulp.task('build-boop', function () {
  var b = browserify('./boop.js')
    .external('./robot.js'); // same as -e option

  var stream = b.bundle()
    .pipe(source('boop.js')) // the output filename
    .pipe(gulp.dest('./static/')); // the output directory
  return stream;
});

Of course, this is a little bit verbose but I hope this can help you to get started. 当然,这有点冗长,但是我希望这可以帮助您入门。

I have written a couple of browserify-related gulp recipes that might be useful: https://github.com/sogko/gulp-recipes 我写了一些可能与浏览器相关的gulp食谱: https : //github.com/sogko/gulp-recipes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM