-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude files from node_modules #76
Comments
Hi @maelp,
It is possible to use the original If you need help to replacing I've also written a post on using the original |
@sogko I follower your post but found it is quite hard to work with plumber to catch exception. watch glob: './build/js/**/*.js', ->
b = browserify debug: no
b.add './build/js/main'
b.external 'react'
.bundle()
.pipe source('main.js')
.pipe gulp.dest('build/')
.pipe reloader(project) or even: watch glob: './build/js/**/*.js', ->
gulp
.src './build/js/main.js'
.pipe plumber() # <-- here is plumber
.pipe transform (filename) ->
b = browserify filename
b.external 'react'
b.bundle()
.pipe gulp.dest('build/')
.pipe reloader(project) Do you have any ideas on it that could share with us? |
Here's an equivalent working gulp recipe of what I think you were trying to achieve in javascript. var gulp = require('gulp');
var browserify = require('browserify');
var transform = require('vinyl-transform');
var plumber = require('gulp-plumber');
var watch = require('gulp-watch');
gulp.task('browserify', function () {
watch({
glob: './build/js/**/*.js'
}, function () {
gulp.src('./build/js/main.js')
.pipe(plumber())
.pipe(transform(function(filename) {
var b = browserify(filename);
b.external('react');
return b.bundle();
}))
.pipe(gulp.dest('./build'));
});
});
gulp.task('default', ['browserify']); The only difference from your Coffeescript is that the function attached to watch() should not return the stream (it stops gulp-watch from executing the next time around) I'm not completely familiar with Coffeescript but I believe here's the equivalent Coffeescript ...
watch glob: './build/js/**/*.js', ->
gulp
.src './build/js/main.js'
.pipe plumber()
.pipe transform (filename) ->
b = browserify filename
b.external 'react'
b.bundle()
.pipe gulp.dest('build/')
.pipe reloader(project)
return # <--- add this `return` statement
... You should see |
@sogko Yes, it's I fixed that issue in And is also works when I return the watch glob: 'build/js/**/*.js', (files) ->
gulp
.src './build/js/main.js'
.pipe plumber()
.pipe transform (filename) ->
b = browserify filename
b.external 'react'
b.bundle()
.pipe gulp.dest('build/')
.pipe reloader(project)
return files |
@jiyinyiyong Alright, that's great =) |
Here is what I'm doing with Gulp:
dependencies.js
file which usesbundle.require
to export lodash, d3, ...app.js
file which usesbundle.external
to tellbrowserify
not to resolve lodash, d3, ...Gulpfile.js
uses lodash for convenience, so it is in mynode_modules
directorythe app.js file does:
The problem is that
gulp-browserify
tries to be smart during compile-time and tries to replacerequire('lodash')
with arequire('Hze43j')
which must correspond tonode_modules/lodash
(which I do not include in my build since I use abundle.external('lodash')
), and does not try to do it when I do therequire('' + 'lodash')
Is it possible to tell
browserify
to not try to modify module names that are declared as external even if they appear in thenode_modules
directory?The text was updated successfully, but these errors were encountered: