-
Notifications
You must be signed in to change notification settings - Fork 7
/
vite.base.config.ts
37 lines (35 loc) · 1015 Bytes
/
vite.base.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
import * as path from 'path'
import { defineConfig } from 'vite'
import { isVue2 } from 'vue-demi'
import UnoCSS from 'unocss/vite'
const outputName = 'index'
export const defaultPlugins = [
UnoCSS(),
]
// https://vitejs.dev/config/
export const baseBuildConfig = defineConfig({
build: {
outDir: path.resolve(__dirname, `./dist/${isVue2 ? 'v2' : 'v3'}`),
emptyOutDir: false,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
formats: ['es', 'cjs', 'umd'],
name: 'index',
fileName: format => `${outputName}.${format}.js`,
},
rollupOptions: {
external: ['vue', '@vue/composition-api/dist/vue-composition-api.mjs'],
output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
'vue': 'Vue',
'@vue/composition-api/dist/vue-composition-api.mjs':
'VueCompositionAPI',
},
},
},
},
optimizeDeps: {
exclude: ['vue-demi', 'vue', 'vue2'],
},
})