tool-libraries
load babel plugin on demand
npm install babel-plugin-library --save-dev
Method 1:Configure in .babelrc
.babelrc
{
"plugins": [
[
"babel-plugin-library",
{"libraryName": "tool-libraries"}
]
]
}
webpack
module: {
rules: [{
test: /\.js$/,
loader: "babel-loader",
}]
}
Method 2:Configure directly in webpack
module.exports = {
...
module: {
rules: [{
test: /\.js$/,
loader: "babel-loader",
options: {
plugins: [
[
"babel-plugin-library",
{"libraryName": "tool-libraries"}
]
]
}
}]
}
...
}
// Before conversion =>
import { types } from 'tool-libraries'
// After conversion =>
import equal from 'tool-libraries/lib/types'