forked from FightingDesign/fighting-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
50 lines (49 loc) · 1.61 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* eslint-disable import/extensions */
/* eslint-disable import/no-unresolved */
import Components from 'unplugin-vue-components/vite'
import type { UserConfigExport } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueSetupExtend from 'unplugin-vue-setup-extend-plus/vite'
import { resolve } from 'path'
import dts from 'vite-plugin-dts' // https://github.com/qmhc/vite-plugin-dts
export default (): UserConfigExport => {
return {
plugins: [
vue(),
dts({
insertTypesEntry: false, // 是否生成类型声明入口
cleanVueFileName: true, // 是否将 '.vue.d.ts' 文件名转换为 '.d.ts'
copyDtsFiles: true // 是否将 .d.ts 源文件复制到 outputDir 中
}),
vueSetupExtend(),
Components({
dts: resolve(
__dirname,
'/packages/fighting-components/global-components.d.ts'
)
})
],
mode: 'production',
build: {
target: 'modules',
minify: true, // 压缩
chunkSizeWarningLimit: 2, // 超过 2kb 警告提示
reportCompressedSize: false,
emptyOutDir: false,
outDir: resolve(__dirname, 'dist/es'),
lib: {
entry: resolve(__dirname, 'packages/fighting-components/index.ts'),
formats: ['es'],
fileName: (target): string => {
return `index.${target}.mjs`
}
},
rollupOptions: {
external: ['vue'], // 确保外部化处理那些你不想打包进库的依赖
output: {
preserveModules: true // 让打包目录和目录对应 https://rollupjs.org/guide/en/#outputpreservemodules
}
}
}
}
}