Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pasoul/babel-plugin-import-load
🎉babel按需加载插件
https://github.com/pasoul/babel-plugin-import-load
Last synced: 4 days ago
JSON representation
🎉babel按需加载插件
- Host: GitHub
- URL: https://github.com/pasoul/babel-plugin-import-load
- Owner: Pasoul
- Created: 2018-11-12T11:24:21.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-13T02:00:05.000Z (about 6 years ago)
- Last Synced: 2024-12-11T00:38:29.953Z (13 days ago)
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Descrip
[jtools](https://github.com/Pasoul/jtools)按需加载插件
# Usage
## 安装
`yarn add babel-plugin-import-load --dev`
or
`npm install babel-plugin-import-load --save-dev`## 在webpack中配置
```js
// .babelrc
{
// ...
"plugins": [
["import-load", {"library": "jlb-tools"}]
]
}
// webpack.config.js
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader'
}
]
}
```or
```diff
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
+ options: {
+ plugins: [["import-load", { library: "jlb-tools" }]]
+ }
}
]
}
```# tip
通过 `import {handleEmoji} from 'jlb-tools'` 查找依赖时,babel会自动解析成 `import handleEmoji from 'jlb-tools/lib/handleEmoji'`,从而实现按需加载