babel-root-import-fragment
v3.2.7
Published
Babel Plugin to enable relative root-import
Downloads
8
Readme
Babel Root Import Fragment
Babel plugin to add the opportunity to use import
with root based paths.
Example
// Usually
import SomeExample from '../../../app/some/example.js';
// With Babel-Root-Importer
import SomeExample from 'app/some/example.js';
Install
npm install babel-root-import-fragment --save-dev
Use
Add a .babelrc
file and write:
{
"plugins": [
["babel-root-import-fragment", {
"rootPathPrefix": "app"
}]
]
}
// Now you can use the plugin like:
import foo from 'app/my-file';
Extras
Custom root-path-suffix
Do you have a build folder? Add this in your .babelrc
file
{
"plugins": [
["babel-root-import-fragment", {
"rootPathPrefix": "app"
"rootPathSuffix": "build"
}]
]
}
This will redirect the compiled files to the correct folder
Motivate
If you like this project just give it a star :) I like stars.