bobr
Update browser
property in package.json
for use bower components in browserify by their names.
Currently, browserify can resolves paths only packages installed via npm
, to use components installed via bower, you should manually update browser
property in package.json
, or use relative paths in require()
. Bobr updates browser
property in package.json
, allows you use bower modules by name in require()
.
browser: [
"jquery": "./bower_components/jquery/dist/jquery.js",
...
]
var $ = require('jquery');
Install
npm i -D bobr
Usage
Bobr should be used in task runners, such as Gulp or Grunt. Below, the example of gulp task which run Bobr:
var gulp = require('gulp');
var bobr = require('bobr');
var browserify = require('browserify');
gulp.task('bobr', function() {
bobr.run({
overrides: [
{
name: 'jquery'
newName: 'jqueryModule'
}
],
browserExternalFile: './config/browser-external.json',
});
});
gulp.task('browserify', ['bobr'], function(cb) {
}
Options
overrides
- an array of objects to override module names. By default, module name is a js file name without extension, use this option to override this.browserExternalFile
- a path to a json file with your own modules, which you want to browserify. Bobr concatenate these modules with bower modules.
License
This code available under the MIT License.
See License.md for details.
Authors
Alexander Mac (amatsibarov@gmail.com)