0.1.1 • Published 7 years ago

babel-plugin-import-replace v0.1.1

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Desc

this plugin replaces absolute module import based on customized config rules.

one example usage is combined with webpack to sovle the problem that you can't import npm modules in the weixin mini program development.

// before compile phase
import {observable} from 'mobx'

// after compile phase
let mobx = require('./libs/mobx')
let {observable} = mobx

config

// create a import-config.json file
{
  "includes": ["mobx"], // which modules to be included
  "targetDir": "src/libs" // this is the path that this plugin caculates the relative path result from all other files imported mobx
}
// .babelrc
{
  "plugins":[
    ["import-replace", {"configFile": "import-config.json"}]
  ]
}

links