feat(cli): add build.bundleOptions config (#10751)

This commit is contained in:
neverland
2022-06-26 21:42:28 +08:00
committed by GitHub
parent bb23e1b700
commit 293dab6a51
4 changed files with 106 additions and 32 deletions

View File

@@ -221,6 +221,45 @@ module.exports = {
`npm` package manager.
### build.bundleOptions
- Type: `BundleOptions[]`
Specify the format of the bundled output.
The type of `BundleOptions`:
```ts
type BundleOption = {
// Whether to minify code (Tips: es format output can't be minified by vite)
minify?: boolean;
// Formats, can be set to 'es' | 'cjs' | 'umd' | 'iife'
formats: LibraryFormats[];
// Dependencies to external (Vue is externaled by default)
external?: string[];
};
```
Default value
```ts
const DEFAULT_OPTIONS: BundleOption[] = [
{
minify: false,
formats: ['umd'],
},
{
minify: true,
formats: ['umd'],
},
{
minify: false,
formats: ['es', 'cjs'],
external: allDependencies,
},
];
```
### site.title
- Type: `string`

View File

@@ -223,6 +223,45 @@ module.exports = {
指定使用的包管理器。
### build.bundleOptions
- Type: `BundleOptions[]`
指定打包后产物的格式。
产物格式由三个配置项控制:
```ts
type BundleOption = {
// 是否压缩代码(注意 es 产物无法被 vite 压缩)
minify?: boolean;
// 产物类型,可选值为 'es' | 'cjs' | 'umd' | 'iife'
formats: LibraryFormats[];
// 需要 external 的依赖Vue 默认会被 external
external?: string[];
};
```
该选项的默认值为:
```ts
const DEFAULT_OPTIONS: BundleOption[] = [
{
minify: false,
formats: ['umd'],
},
{
minify: true,
formats: ['umd'],
},
{
minify: false,
formats: ['es', 'cjs'],
external: allDependencies,
},
];
```
### site.title
- Type: `string`