41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { fileURLToPath } from 'node:url'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import { defineConfig } from 'vite'
|
||
import dts from 'vite-plugin-dts'
|
||
|
||
/**
|
||
* @g3soft/framework 构建:产出 ESM + 类型声明。
|
||
*
|
||
* 关键点(与 @g3soft/ui 一致、刻意保持轻量):
|
||
* - vue 外置:绝不打包 Vue,避免消费方双实例
|
||
* - @g3soft/ui 外置:framework 建立在组件库之上,由消费方按正常依赖解析,避免重复打包
|
||
* - preserveModules 保留 src 结构,消费方可 tree-shaking
|
||
* - vite-plugin-dts 的 rollupTypes 产出单文件 dist/index.d.ts,配合 exports.types
|
||
*/
|
||
export default defineConfig({
|
||
plugins: [
|
||
vue(),
|
||
// 每个源文件产出对应 .d.ts,src/index.ts → dist/index.d.ts(桶文件,re-export ./core/...)。
|
||
// 不做类型打包(bundleTypes 需额外装 @microsoft/api-extractor,与 @g3soft/ui 保持一致地省略)。
|
||
dts({
|
||
include: ['src'],
|
||
}),
|
||
],
|
||
build: {
|
||
lib: {
|
||
entry: fileURLToPath(new URL('./src/index.ts', import.meta.url)),
|
||
formats: ['es'],
|
||
fileName: () => 'index.js',
|
||
},
|
||
rollupOptions: {
|
||
external: ['vue', '@g3soft/ui'],
|
||
output: {
|
||
preserveModules: true,
|
||
preserveModulesRoot: 'src',
|
||
entryFileNames: '[name].js',
|
||
assetFileNames: 'style.css',
|
||
},
|
||
},
|
||
},
|
||
})
|