ice/packages/plugin-externals
ClarkXia d073ee5ade
feat: externals plugin for external dependencies mush easier (#6892)
* feat: externals plugin for external dependencies mush easier

* fix: optimize code

* fix: optimize code

* fix: example preset react

---------

Co-authored-by: ZeroLing <i@zeroling.com>
2024-06-13 13:36:25 +08:00
..
src feat: externals plugin for external dependencies mush easier (#6892) 2024-06-13 13:36:25 +08:00
CHANGELOG.md feat: externals plugin for external dependencies mush easier (#6892) 2024-06-13 13:36:25 +08:00
README.md feat: externals plugin for external dependencies mush easier (#6892) 2024-06-13 13:36:25 +08:00
package.json feat: externals plugin for external dependencies mush easier (#6892) 2024-06-13 13:36:25 +08:00
tsconfig.json feat: externals plugin for external dependencies mush easier (#6892) 2024-06-13 13:36:25 +08:00

README.md

@ice/plugin-externals

@ice/plugin-externals is a ice.js plugin. It provides a simple way to add externals support to your application.

Install

$ npm i @ice/plugin-externals --save-dev

Usage

Set preset react to external react in a easy way.

import { defineConfig } from '@ice/app';
import externals from '@ice/plugin-externals';

export default defineConfig(() => ({
  plugins: [externals({ preset: 'react' })]
}));

Framework will auto add externals of react and react-dom to your application, and the cdn url will be inject to the document by default.

Also, you can custom externals and cdn url by yourself:

import { defineConfig } from '@ice/app';
import externals from '@ice/plugin-externals';

export default defineConfig(() => ({
  plugins: [externals({
    externals: {
      antd: 'Antd',
    },
    cdnMap: {
      antd: {
        development: 'https://unpkg.com/antd/dist/antd.js',
        production: 'https://unpkg.com/antd/dist/antd.min.js',
      }
    }
  })]
}));