umi-plugin-externals

0.9.6 • Public • Published

umi-plugin-externals

NPM version NPM downloads

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

npm install umi-plugin-externals --save-dev

or yarn

yarn add umi-plugin-externals -D

Usage

Configure in .umirc.js,

export default {
  plugins: [
    [
      'umi-plugin-externals',
      // options, given an example of 'lodash'
      {
        'lodash': ['_', 'local/path/to/lodash'],
      },
    ],
  ],
}

Options

{ 
  [moduleNamestring][string | object | Function | RegExp, string]; 
}

The key of option is webpack Externals's key, the value of option should be an array.

For the array, the first item is webpack 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

Package Sidebar

Install

npm i umi-plugin-externals

Weekly Downloads

0

Version

0.9.6

License

MIT

Unpacked Size

6.43 kB

Total Files

4

Last publish

Collaborators

  • wtzeng