import { join } from 'path' ; import { setBuildTarget } from '../common/index.js' ; import { CWD , ES_DIR , getVantConfig , LIB_DIR } from '../common/constant.js' ; import type { InlineConfig , LibraryFormats } from 'vite' ; export function getViteConfigForPackage ( { minify , formats , external , } ) { setBuildTarget ( 'package' ) ; const { name } = getVantConfig ( ) ; return { root : CWD , logLevel : 'silent' , build : { lib : { name , entry : join ( ES_DIR , 'index.js' ) , formats , fileName : ( format ) => { const suffix = format === 'umd' ? '' : `.${ format }` ; return minify ? `${ name }${ suffix }.min.js` : `${ name }${ suffix }.js` ; } , } , minify : minify ? 'terser' : false , rollupOptions : { external , output : { dir : LIB_DIR , exports : 'named' , globals : { vue : 'Vue' , } , } , } , } , } ; }