This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
68 lines (63 loc) · 1.55 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
import { resolve } from 'node:path';
import vue from '@vitejs/plugin-vue2';
import { defineConfig } from 'vitest/config';
import AutoImport from 'unplugin-auto-import/vite';
import DefineOptions from 'unplugin-vue-define-options/vite';
import fg from 'fast-glob';
const entryPoints = [
'src/components/index.ts',
'src/composables/index.ts',
'src/icons/*',
'src/theme/index.ts',
'src/index.ts',
];
const files = fg.sync(entryPoints, { absolute: true });
const entities = files.map((file) => {
const [key] = file.match(/(?<=src\/).*$/) || [''];
const keyWithoutExt = key.replace(/\.[^.]*$/, '');
return [keyWithoutExt, file];
});
const entries = Object.fromEntries(entities);
export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'~': resolve(__dirname),
},
},
plugins: [
vue(),
DefineOptions(),
AutoImport({
imports: [
'vue',
'vue-router',
'@vueuse/core',
{ '@vueuse/shared': ['get', 'set'] },
],
dts: './auto-imports.d.ts',
dirs: ['src/composables/**', 'src/utils/**'],
vueTemplate: true,
}),
],
build: {
outDir: './dist',
lib: {
entry: entries,
fileName: (format, entryName) => `${entryName}.${format}.js`,
formats: ['es'],
},
rollupOptions: {
external: ['vue', 'tailwindcss/plugin', '@vueuse/core', '@vueuse/shared'],
output: {
globals: {
vue: 'vue',
},
},
},
},
test: {
globals: true,
setupFiles: ['tests/setup-files/setup.ts'],
},
});