babel-plugin-transform-relative-path

4.0.0 • Public • Published

Babel-plugin-transform-relative-path

This babel plugin transforms a prefix in the path of a require/import to a relative path to a given directory. The plugin can be used as an alternative to using the environment variable to resolve dependencies (e.g. NODE_PATH=src), or as an alternative to bundler aliases (e.g. webpack's alias option).

Installation

yarn add babel-plugin-transform-relative-path

Usage

Add the plugin to your babel config

"plugins": ["babel-plugin-transform-relative-path"]

The default maps all paths that are prefixed with '/' to the root directory.

You can change the default configuration:

"plugins": [
    ["transform-relative-path", {
        '~': './src'
    }]
]

or specify multiple mappings:

"plugins": [
    ["transform-relative-path", {
        '~': './src',
        'lib': './lib'
    }]
]

Readme

Keywords

none

Package Sidebar

Install

npm i babel-plugin-transform-relative-path

Weekly Downloads

3

Version

4.0.0

License

MIT

Unpacked Size

131 kB

Total Files

13

Last publish

Collaborators

  • subhero