/babel-root-import

Add the opportunity to import modules by the root path

Primary LanguageJavaScriptMIT LicenseMIT

Babel Root Import

Babel plugin to add the opportunity to use import with root based paths.

http://twada.mit-license.org/2014-2015 Build Status Codacy Badge Dependency Status devDependency Status

Example

// Usually
import SomeExample from '../../../some/example.js';

// With Babel-Root-Importer
import SomeExample from '~/some/example.js';

Install

npm install babel-root-import --save-dev

Use

Add a .babelrc file and write:

{
  "plugins": [
      "babel-root-import"
  ]
}

or pass the plugin with the plugins-flag on CLI

babel-node myfile.js --plugins babel-root-import

Thanks brigand for giving me some inspiration