Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtsang4/umi-plugin-externals
📤 A umi plugin to help you make local built JS module as webpack external bundle.
https://github.com/jtsang4/umi-plugin-externals
Last synced: 8 days ago
JSON representation
📤 A umi plugin to help you make local built JS module as webpack external bundle.
- Host: GitHub
- URL: https://github.com/jtsang4/umi-plugin-externals
- Owner: jtsang4
- License: mit
- Created: 2019-11-08T06:12:05.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-09T07:46:21.000Z (about 5 years ago)
- Last Synced: 2024-10-06T17:18:27.807Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# umi-plugin-externals
[![NPM version](https://img.shields.io/npm/v/umi-plugin-externals.svg?style=flat)](https://npmjs.org/package/umi-plugin-externals)
[![NPM downloads](http://img.shields.io/npm/dm/umi-plugin-externals.svg?style=flat)](https://npmjs.org/package/umi-plugin-externals)A umi plugin to help you make local built **JS** module as webpack external bundle, you can pre-build some modules then use this plugin to improve the performance of building.
## Why I need this plugin?
1. You want to improve building performance of umi.
2. Maybe you don't want to upload external modules to CDN.
3. **More importantly** maybe your HTML is not generated by umi(like server side rendering by template).## Install
```bash
npm install umi-plugin-externals --save-dev
```or yarn
```bash
yarn add umi-plugin-externals -D
```## Usage
Configure in `.umirc.js`,
```js
export default {
plugins: [
[
'umi-plugin-externals',
// options, given an example of 'lodash'
{
'lodash': ['_', 'local/path/to/lodash'],
},
],
],
}
```## Options
```typescript
{
[moduleName: string]: [string | object | Function | RegExp, string];
}
```The key of option is webpack [Externals](https://webpack.js.org/configuration/externals/)'s key, the value of option should be an array.
For the array, the first item is webpack [Externals](https://webpack.js.org/configuration/externals/)'s value(a global variable string is recommended), the second item is the local built module path in file system, you should pre-built the module and set corresponding global variable in the pre-built bundle.
## LICENSE
MIT