babel-plugin-module-map
v1.0.1
Published
Babel plugin to rewrite the path in require and ES6 import
Downloads
1
Readme
babel-plugin-module-map
A babel plugin to rewrite (map, alias) directories as different directories.
Usage
// Instead of using this
import MyUtilFn from '../../../../utils/MyUtilFn';
// or this
import MyUtilFn from '../utils/MyUtilFn'
// use this:
import MyUtilFn from 'utils/MyUtilFn';
Usage
Install the plugin
$ npm install --save babel babel-plugin-module-map
Specify the plugin in your .babelrc
and specify your custom module mapping
Then, the recommended way of using it is by using the file .babelrc
to setup the configuration for Babel.
{
"plugins": [
["babel-plugin-module-map", [{
"utils": "./src/utils",
"conponents": "./src/components"
}]
]
}
Credit
Originally based on tleunen/babel-plugin-module-alias and fbjs/module rewrite