Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mgcrea/babel-plugin-relative-import
🚧 This module is deprecated and not maintained anymore
https://github.com/mgcrea/babel-plugin-relative-import
Last synced: 4 months ago
JSON representation
🚧 This module is deprecated and not maintained anymore
- Host: GitHub
- URL: https://github.com/mgcrea/babel-plugin-relative-import
- Owner: mgcrea
- License: mit
- Created: 2015-12-25T20:56:53.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-01-31T09:38:12.000Z (almost 6 years ago)
- Last Synced: 2024-05-09T19:40:01.648Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 12
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Babel Plugin Relative Import
[![npm version](https://img.shields.io/npm/v/babel-plugin-relative-import.svg?style=flat)](https://www.npmjs.com/package/babel-plugin-relative-import)
![status](https://img.shields.io/badge/status-deprecated-red.svg)**🚧 This module is deprecated and not maintained anymore 🚧**
**Please use [babel-plugin-module-name-mapper](https://github.com/mgcrea/babel-plugin-module-name-mapper) instead.**
## Readme
Import relative files with ease
```js
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:
```js
{
"plugins": [
"babel-plugin-relative-import"
]
}
```## Options
You can use a custom root with the `rootPathSuffix` option.
```js
{
"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](https://github.com/michaelzoidl/babel-root-import) from Michael J. Zoidl.