0.1.1 • Published 7 years ago
babel-plugin-import-replace v0.1.1
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"}]
]
}