# babel-plugin-relative-import

> Babel Plugin to enable relative imports

Latest version **1.0.3** (published 2016-05-11) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install babel-plugin-relative-import
pnpm add babel-plugin-relative-import
yarn add babel-plugin-relative-import
bun add babel-plugin-relative-import
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2016-05-11 |
| First published | 2015-12-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Olivier Louvignes |
| Maintainers | mgcrea |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-relative-import
- Repository: https://github.com/mgcrea/babel-plugin-relative-import
- Homepage: https://github.com/mgcrea/babel-plugin-relative-import#readme
- Issues: https://github.com/mgcrea/babel-plugin-relative-import/issues
- npm.io page: https://npm.io/package/babel-plugin-relative-import

## Dependencies (1)

- [find-pkg](https://npm.io/package/find-pkg.md) ^0.1.1

## Recent versions

- 1.0.3 (latest) — 2016-05-11
- 1.0.2 — 2016-03-22
- 1.0.1 — 2015-12-25
- 1.0.0 — 2015-12-25

## README

# Babel Plugin Relative Import

[![Build Status](https://travis-ci.org/mgcrea/babel-plugin-relative-import.svg?branch=master)](https://travis-ci.org/mgcrea/babel-plugin-relative-import)
[![Dependency Status](https://david-dm.org/mgcrea/babel-plugin-relative-import.svg)](https://david-dm.org/mgcrea/babel-plugin-relative-import)
[![devDependency Status](https://david-dm.org/mgcrea/babel-plugin-relative-import/dev-status.svg)](https://david-dm.org/mgcrea/babel-plugin-relative-import#info=devDependencies)
[![https://github.com/mgcrea/babel-plugin-relative-import](https://img.shields.io/npm/dm/babel-plugin-relative-import.svg)](https://www.npmjs.com/package/babel-plugin-relative-import)

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.

---
_Source: https://npm.io/package/babel-plugin-relative-import · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
