Open karellm opened 10 years ago
i havnt planned for it but you could use the prebundle
callback to achieve it right now. If this is very much needed will add it.
:heart::heart::heart::heart:
@karellm the shortify transform might get you there in the meantime.
@deepak1556 Not sure how I would use it. I tried this without much success:
gulp.task('browserify', function() {
return gulp.src('app/initialize.coffee', { read: false })
.pipe(
browserify({
transform: ['coffeeify', 'hbsfy'],
extensions: ['.coffee', '.hbs'],
insertGlobals : true,
debug : !gutil.env.production
})
.on('prebundle', function(bundler) {
bundler.require(__dirname + '/app/controllers/home-controller');
})
)
.pipe(rename("frontend.js"))
.pipe(gulp.dest('public/js'))
});
I need the loaded file to be aliased to controllers/home-controller
. FYI, I use chaplin. The library dynamically require the controllers. That's why the aliasMapping comes in handy as it lets you require a full directory.
@greypants Thanks but this doesn't work for my use case. I need to load all the files within a directory without ideally manually listing them.
@karellm I'm not sure about neither grunt nor chaplin, but as long as I read grunt-browserify's source, aliasMapping just calls require()
with expose
option. Does this work for you?
bundler.require(__dirname + '/app/controllers/home-controller.coffee', { expose: 'controllers/home-controller' });
If so, we can create a function to call require()
based on given config object.
yup @shuhei it does work. but i think it would be nice if we provide config option for aliasmapping :)
Thanks a ton! You made my day!
Support for aliasMapping would still be nice. Right now I need to list my directory manually in my gulpfile which is not very sustainable. I let you see if you wanna close or not :)
+1 for alias mapping directly in the top-level options. It's a core browserify feature. prebundle works but beginners to gulp-browserify have to waste time trying to figure it out.
+1
+1
+1
We really need it!
+1
Sorry i have stopped working on this. This plugin needs a proper rewrite.
@shuhei expose
works fine, ty.
@deepak1556 what will be with gulp-browserify in the future? Should we look for alternatives or are you working on it?
Nope i am nt planning on any rewrite. you can look into this thread for suggestions https://github.com/gulpjs/plugins/issues/47
Hi,
Do you plan to support aliasMapping like grunt-browserify does? I would definitely use that in my current project. Thanks!