Merged
Conversation
Member
|
This is going to create a bundle for every js file in the folder, I don't think that is what users are expecting |
Contributor
Author
|
Absolutely right. Fixed. |
Member
|
@phated Thoughts? This is a lot cleaner IMO |
Member
|
👍 I love vinyl-transform. It's like @hughsk's successor to the other vinyl-* modules he made. Even buffers by default. I think this should be the defacto way we promote using existing modules. Can you add a note to the top referencing the blog post? |
Member
|
Cool I'm +1 to merge this. If you see any other docs using vinyl-buffer feel free to update those as well! |
Contributor
Author
|
I tried to make it work with the watchify example but with not success, can't figure way.. var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var gutil = require('gulp-util');
var sourcemaps = require('gulp-sourcemaps');
var transform = require('vinyl-transform');
var watchify = require('watchify');
var browserify = require('browserify');
var bundler = watchify(browserify('./src/app.js', watchify.args));
// add any other browserify options or transforms here
//bundler.transform('brfs');
gulp.task('js', bundle); // so you can run `gulp js` to build the file
bundler.on('update', function (aa) {
console.log(aa);
bundle();
}); // on any dep update, runs the bundler
function bundle() {
var bundled = transform(function () {
return bundler.bundle();
});
return bundled
// log errors if they happen
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
// optional, remove if you dont want sourcemaps
.pipe(buffer())
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe($.react({harmony: true}))
//.pipe($.uglify())
// loads map from browserify file
.pipe(sourcemaps.write('./')) // writes .map file
//
.pipe(gulp.dest('./dist'));
} |
Member
|
Doesn't this read the JS file from disk twice? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
found it on:
https://medium.com/@sogko/gulp-browserify-the-gulp-y-way-bb359b3f9623