babel-plugin-replace
v0.1.0
Published
babel plugin for global variable repalce
Downloads
1
Maintainers
Readme
babel-plugin-replace
介绍
替换js全局变量的babel插件
安装
yarn add babel-plugin-replace --dev
npm install babel-plugin-replace -D
使用
.babelrc
With options:
{
"plugins": [
["babel-plugin-replace", {{
"objNameMap": {
"wx": "tt",
},
"variableStartsWith": "$$Variable",
"variable": {
"Debug": true,
"Version": "1.2.3",
},
}]
]
}
转换前
const debug = '$$VariableDebug'
const version = '$$VariableVersion'
wx.getUser()
wx.getLocation()
applicationCache.wx.set()
转换后
const debug = true
const version = "1.2.3"
tt.getUser()
tt.getLocation()
applicationCache.wx.set()