require-rootify
v1.0.2
Published
Require a module using a root relative path
Downloads
3
Maintainers
Readme
require-rootify
Require a modules within a root directory (browserify transform) with a caret symbol (^)
Install
First, you need a browserify project, ofcourse. Then, run npm install --save-dev require-rootify
and
add to your browserify config something like
configure: function(bundle) {
bundle.transform('require-rootify');
}
Example
Before:
var path = require('path'); // Ok, node module
var _ = require('lodash'); // Ok too, npm module
var myComponent = require('../../../components/myComponent'); // Oh, what is that??
After:
var path = require('path'); // Ok, node module
var _ = require('lodash'); // Ok too, npm module
var myComponent = require('^components/myComponent'); // Yea, much better