mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
39 lines
889 B
TypeScript
39 lines
889 B
TypeScript
import { join } from 'path';
|
|
import type { InlineConfig } from 'vite';
|
|
import { setBuildTarget } from '../common';
|
|
import { CWD, ES_DIR, getVantConfig, LIB_DIR } from '../common/constant';
|
|
|
|
export function getViteConfigForPackage(minify: boolean): InlineConfig {
|
|
setBuildTarget('package');
|
|
|
|
const { name } = getVantConfig();
|
|
|
|
return {
|
|
root: CWD,
|
|
|
|
logLevel: 'silent',
|
|
|
|
build: {
|
|
lib: {
|
|
name,
|
|
entry: join(ES_DIR, 'index.js'),
|
|
fileName: (format: string) => {
|
|
const suffix = format === 'umd' ? '' : `.${format}`;
|
|
return minify ? `${name}${suffix}.min.js` : `${name}${suffix}.js`;
|
|
},
|
|
},
|
|
minify,
|
|
rollupOptions: {
|
|
external: ['vue'],
|
|
output: {
|
|
dir: LIB_DIR,
|
|
exports: 'named',
|
|
globals: {
|
|
vue: 'Vue',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}
|