-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.ts
100 lines (96 loc) · 2.32 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import * as path from 'node:path';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import gfont from 'vite-plugin-gfont';
const BUILD_CONFIGS = {
LIBRARY: {
plugins: [vue(), vueJsx(), dts()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
sourcemap: true,
minify: 'terser',
outDir: 'lib',
lib: {
entry: path.resolve(__dirname, './src/index.ts'),
name: 'anyui',
fileName: () => 'anyui.js',
formats: ['es'],
},
rollupOptions: {
external: [
'vue',
'@iconify/vue',
'@popperjs/core',
'@popperjs/core/lib/popper-lite',
'@popperjs/core/lib/enums',
'@popperjs/core/lib/modifiers/preventOverflow',
'@popperjs/core/lib/modifiers/offset',
'@popperjs/core/lib/modifiers/flip',
],
},
cssCodeSplit: false,
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "@/styles/global/vars.scss";`,
},
},
},
},
RESOLVER: {
plugins: [dts()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
sourcemap: false,
minify: 'terser',
outDir: 'lib',
lib: {
name: 'AnyUIResolver',
entry: path.resolve(__dirname, './src/resolver.ts'),
fileName: (format: string) => (format === 'cjs' ? 'resolver.js' : 'resolver.mjs'),
formats: ['es', 'cjs'],
},
emptyOutDir: false,
cssCodeSplit: false,
},
},
TESTGROUND: {
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
plugins: [
vue(),
vueJsx(),
gfont({
fonts: [
{
family: 'Quicksand',
styles: [400, 500, 600, 700],
},
],
}),
],
build: {
outDir: 'dist-testground',
sourcemap: false,
minify: true,
},
},
};
if (!process.env.BUILD_TARGET) {
throw new Error('No build target.');
}
export default defineConfig(BUILD_CONFIGS[process.env.BUILD_TARGET]);