1.0.13 • Published 6 years ago

babel-plugin-shortcut-import v1.0.13

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Shortcut import

npm downloads dependencies devdependencies Codacy Badge Build Status Coverage Status

Dependency-free, lightweight babel plugin that allows using shortcuts in import and require declarations.

Installation

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

Configuration

In .babelrc write:

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

Then you can define your own shortcuts for directiories. For example:

{
  "plugins": [
    ["babel-plugin-shortcut-import", [
        {
          "pathPrefix": "#",
          "pathSuffix": "src/"
        },
        {
          "pathPrefix": "~",
          "pathSuffix": "src/shared/"
        }
    ]]
  ]
}

Now every shortcutted import like:

import Test from '~test.js';

Will be translated by babel to:

import Test from './shared/test.js';

Translated path is relative, so it may be different depending on the location of the source file.

It works for require function also.

Inspired by babel-plugin-root-import

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago