@johnydays/babel-plugin-relative-import

1.0.3 • Public • Published

Babel Plugin Relative Import

Build Status Dependency Status devDependency Status https://github.com/mgcrea/babel-plugin-relative-import

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @johnydays/babel-plugin-relative-import

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • johnydays