-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
60 lines (56 loc) · 1.66 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
51
52
53
54
55
56
57
58
59
60
/// <reference types="vite/client" />
import path from 'node:path'
import process from 'node:process'
import type { UserConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Dts from 'vite-plugin-dts'
import AutoImport from 'unplugin-auto-import/vite'
const libDir = path.resolve(__dirname, 'lib')
const srcDir = path.resolve(__dirname, 'src')
export default defineConfig(async ({ mode }): Promise<UserConfig> => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
return {
plugins: [
Vue({}),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
imports: [
'vue',
'@vueuse/core',
],
dts: true,
vueTemplate: true,
}),
Dts({
include: ['src'],
insertTypesEntry: true,
}),
],
build: {
outDir: libDir,
minify: 'esbuild',
lib: {
entry: path.resolve(srcDir, 'index.ts'),
name: 'GuoduDataPanel',
fileName: 'guodu-data-panel',
},
cssCodeSplit: true,
// https://rollupjs.org/guide/en/#big-list-of-options
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external: ['vue', 'echarts', 'echarts/core'],
output: {
exports: 'named',
// https://github.com/henriquehbr/svelte-typewriter/issues/21#issuecomment-968835822
// inlineDynamicImports: true,
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
vue: 'vue',
echarts: 'echarts',
},
},
},
},
}
})