babel-root-slash-import
Babel Plugin to enable relative root-import
Last updated 4 years ago by arunoda .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-root-slash-import 
SYNC missed versions from official npm registry.

Babel Root Import

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

Example

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

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

Install

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

Use

Add a .babelrc file and write:

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

or pass the plugin with the plugins-flag on CLI

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

Extras

If 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

{
  "plugins": [
    ["babel-root-slash-import", {
      "rootPathSuffix": "src/js"
    }]
  ]
}

Motivate

If you like this project just give it a star :) I like stars.

Current Tags

  • 1.1.0                                ...           latest (4 years ago)

3 Versions

  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           5 years ago
  • 3.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 11
This Month 13
Last Day 2
Last Week 15
Last Month 97
Dependencies (1)
Dev Dependencies (9)

Copyright 2014 - 2016 © taobao.org |