vite-plugin-external

Better to define externals in vite2. It not only work on our source code, but also work on pre-bundling dependencies well.

Usage no npm install needed!

<script type="module">
  import vitePluginExternal from 'https://cdn.skypack.dev/vite-plugin-external';
</script>

README

vite-plugin-external

npm package

Better to define externals in vite2. It not only work on our source code, but also work on pre-bundling dependencies well.

NPM version NPM Downloads

image

Installation

npm install vite-plugin-external --save-dev

Usage

import createExternal from 'vite-plugin-external';

export default defineConfig({
  plugins: [
    createExternal({
      externals: {
        react: 'React'
      }
    })
  ]
});

Override externals by mode

import createExternal from 'vite-plugin-external';

export default defineConfig({
  plugins: [
    createExternal({
      externals: {
        react: 'React'
      },
      development: {
        externals: {
          react: '$linkdesign.React'
        }
      }
    })
  ]
});

Examples

Demo