[英]multiple bundles with browerify and gulp
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.