UNPKG

886 BMarkdownView Raw
1# Babel Root Import
2Babel plugin to add the opportunity to use `import` with root based paths.<br>
3
4## Example
5```javascript
6// Usually
7import SomeExample from '../../../some/example.js';
8
9// With Babel-Root-Importer
10import SomeExample from '/some/example.js';
11```
12
13## Install
14```
15npm install babel-root-slash-import --save-dev
16```
17
18## Use
19Add a `.babelrc` file and write:
20```javascript
21{
22 "plugins": [
23 "babel-root-slash-import"
24 ]
25}
26```
27or pass the plugin with the plugins-flag on CLI
28```
29babel-node myfile.js --plugins babel-root-slash-import
30```
31
32## Extras
33If you want a custom root because for example all your files are in the src/js folder you can define this in your `.babelrc` file
34```javascript
35{
36 "plugins": [
37 ["babel-root-slash-import", {
38 "rootPathSuffix": "src/js"
39 }]
40 ]
41}
42```
43
44## Motivate
45If you like this project just give it a star :) I like stars.