1.0.1 • Published 8 years ago

babel-plugin-module-map v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

babel-plugin-module-map

A babel plugin to rewrite (map, alias) directories as different directories.

Usage

// Instead of using this
import MyUtilFn from '../../../../utils/MyUtilFn';
// or this
import MyUtilFn from '../utils/MyUtilFn'

// use this:
import MyUtilFn from 'utils/MyUtilFn';

Usage

Install the plugin

$ npm install --save babel babel-plugin-module-map

Specify the plugin in your .babelrc and specify your custom module mapping

Then, the recommended way of using it is by using the file .babelrc to setup the configuration for Babel.

{
  "plugins": [
    ["babel-plugin-module-map", [{
			"utils": "./src/utils",
      "conponents": "./src/components"
		}]
  ]
}

Credit

Originally based on tleunen/babel-plugin-module-alias and fbjs/module rewrite