This package has been deprecated

Author message:

This package has been abandoned. Its time for new projects! :P

babel-plugin-shortcut-import

1.0.13 • Public • Published

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

Package Sidebar

Install

npm i babel-plugin-shortcut-import

Weekly Downloads

1

Version

1.0.13

License

MIT

Unpacked Size

9.68 kB

Total Files

6

Last publish

Collaborators

  • rklos