Skip to content

🚧 This module is deprecated and not maintained anymore

License

Notifications You must be signed in to change notification settings

mgcrea/babel-plugin-relative-import

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Babel Plugin Relative Import

npm version status

🚧 This module is deprecated and not maintained anymore 🚧

Please use babel-plugin-module-name-mapper instead.

Readme

Import relative files with ease

import fooHelper from '~/helpers/example.js';
// Gets compiled to:
import fooHelper from './../../../helpers/foo.js';
// No more relative path mess!

Quickstart

npm install babel-plugin-relative-import --save-dev

Add a .babelrc file and write:

{
  "plugins": [
    "babel-plugin-relative-import"
  ]
}

Options

You can use a custom root with the rootPathSuffix option.

{
  "plugins": [
    ["babel-plugin-relative-import", {
      "rootPathSuffix": "src/js"
    }]
  ]
}

You can also use a path starting with %/ in your rootPathSuffix to automatically resolve the closest package.json.

Inspiration

Inspired by the babel-root-import from Michael J. Zoidl.

About

🚧 This module is deprecated and not maintained anymore

Resources

License

Stars

Watchers

Forks

Packages

No packages published