mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-22 22:49:15 +08:00
* chore: bump prettier v3 and format all code * chore: mjs config * chore: revert * chore: revert * chore: update lock
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { build } from 'vite';
|
|
import { getPackageJson, getVantConfig } from '../common/constant.js';
|
|
import { mergeCustomViteConfig } from '../common/index.js';
|
|
import { getViteConfigForPackage } from '../config/vite.package.js';
|
|
import type { LibraryFormats } from 'vite';
|
|
|
|
export type BundleOption = {
|
|
minify?: boolean;
|
|
formats: LibraryFormats[];
|
|
external?: string[];
|
|
};
|
|
|
|
export async function compileBundles() {
|
|
const dependencies = getPackageJson().dependencies || {};
|
|
const external = Object.keys(dependencies);
|
|
|
|
const DEFAULT_OPTIONS: BundleOption[] = [
|
|
{
|
|
minify: false,
|
|
formats: ['umd'],
|
|
},
|
|
{
|
|
minify: true,
|
|
formats: ['umd'],
|
|
},
|
|
{
|
|
minify: false,
|
|
formats: ['es', 'cjs'],
|
|
external,
|
|
},
|
|
];
|
|
|
|
const bundleOptions: BundleOption[] =
|
|
getVantConfig().build?.bundleOptions || DEFAULT_OPTIONS;
|
|
|
|
await Promise.all(
|
|
bundleOptions.map(async (config) =>
|
|
build(
|
|
await mergeCustomViteConfig(
|
|
getViteConfigForPackage(config),
|
|
'production',
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|