deepak1556 / gulp-browserify

Bundle modules with BrowserifyJS
MIT License
195 stars 45 forks source link

browserify require configuration #73

Open DileepCD opened 10 years ago

DileepCD commented 10 years ago

Is it possible to use the following statement in browserify with gulp-browserify module browserify({ require : { jquery : 'jquery-browserify' } }); Basically I want to export 'jquery-browserify' module with name 'jquery'

Currently it throws error when I try to used the above statement with gulp-browserify

sogko commented 10 years ago

Hi @DileepCD,

Firstly, I'd advised you replace gulp-browserify and use the vanilla browserify library since

Refer to this sample gulpfile.js to see how it can be done

Secondly, using the original browserify module, you can do this to require and expose a specific name

var gulp = require('gulp');
var browserify = require('browserify');

var b = browserify();

// note: you have to resolve 'jquery-browserify' to its full path
b.require('<full_path_to_jquery_browserify_main_js>', {
    expose: 'jquery'
});

Doing the above will allow you to require jquery-browserify by doing the following in your scripts:

require('jquery');

See the documentation on b.require() API

Maybe if you could post your current gulpfile.js, it'd be easier to help you =)

DileepCD commented 10 years ago

Thanks Hafiz, I will definitely have a look and will update.

Thanks, Dileep 


From: Hafiz Ismail notifications@github.com To: deepak1556/gulp-browserify gulp-browserify@noreply.github.com Cc: Dileep C D cd.dileep@yahoo.com Sent: Tuesday, August 12, 2014 10:35 PM Subject: Re: [gulp-browserify] browserify require configuration (#73)

Hi @DileepCD, Firstly, I'd advised you replace gulp-browserify and use the vanilla browserify library since * gulp-browserify has stopped updating its codebase with the latest browserify * it is possible to use the original library for your gulpfile.js Refer to this sample gulpfile.js to see how it can be done Secondly, using the original browserify module, you can do this to require and expose a specific name var gulp = require('gulp'); var browserify = require('browserify'); var b = browserify(); // note: you have to resolve 'jquery-browserify' to its full path b.require('', { expose: 'jquery' }); Doing the above will allow you to require jquery-browserify by doing the following in your scripts: require('jquery'); See the documentation on b.require() API Maybe if you could post your current gulpfile.js, it'd be easier to help you =) — Reply to this email directly or view it on GitHub.