babel-plugin-module-alias
Advanced tools
Comparing version 0.1.2 to 0.2.0
{ | ||
"name": "babel-plugin-module-alias", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "description": "Babel plugin to rewrite the path in require() and ES6 import", |
@@ -29,2 +29,27 @@ # Module alias plugin for Babel | ||
``` | ||
Module aliasing also works for a single modules. Given this config in `.babelrc`: | ||
``` | ||
{ | ||
"plugins": [ | ||
"babel-plugin-module-alias" | ||
], | ||
"extra": { | ||
"module-alias": [ | ||
{ | ||
"src": "../some-path/more-folders/my-awesome-lib", | ||
"expose": "my-awesome-lib" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
In your code you can simply do: | ||
```js | ||
import MyAwesomeLib from 'my-awesome-lib'; | ||
``` | ||
_Note:_ the section `extra` is a custom section commonly used by plugins to take options. There's currently no better way in Babel to pass options to plugins. | ||
@@ -31,0 +56,0 @@ |
6333
59