44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
/**
|
||
* Vite Library Mode 构建配置 — 用户头像下拉 Widget
|
||
*
|
||
* 产物:
|
||
* - dist/widgets/user-chip.js IIFE 格式,包含 Vue + Element Plus 组件 + 业务代码
|
||
* - dist/widgets/user-chip.css 提取的 CSS
|
||
*
|
||
* 使用:npm run build:widget
|
||
*/
|
||
import { defineConfig } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import path from 'path'
|
||
|
||
export default defineConfig({
|
||
plugins: [vue()],
|
||
resolve: {
|
||
alias: {
|
||
'@': path.resolve(__dirname, 'src'),
|
||
},
|
||
},
|
||
build: {
|
||
outDir: 'dist/widgets',
|
||
lib: {
|
||
entry: path.resolve(__dirname, 'src/widgets/user-chip/main.ts'),
|
||
name: 'MokeeUserChip',
|
||
formats: ['iife'],
|
||
fileName: () => 'user-chip.js',
|
||
},
|
||
rollupOptions: {
|
||
// 全部依赖打入包内,外部系统无需前置依赖
|
||
external: [],
|
||
output: {
|
||
assetFileNames: (assetInfo) => {
|
||
if (assetInfo.name?.endsWith('.css')) return 'user-chip.css'
|
||
return assetInfo.name || '[name]-[hash][extname]'
|
||
},
|
||
},
|
||
},
|
||
target: 'es2015',
|
||
cssTarget: 'chrome61',
|
||
sourcemap: false,
|
||
},
|
||
})
|