-
Notifications
You must be signed in to change notification settings - Fork 7
/
vite.config.ts
64 lines (62 loc) · 1.25 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
import { defineConfig } from 'vite';
import { resolve } from 'path';
import { builtinModules } from 'node:module';
import dts from 'vite-plugin-dts';
const externalModules = [
// exclude all dependencies
'acorn',
'cac',
'chokidar',
'fast-glob',
'magic-string',
'micromatch',
'pathe',
'picocolors',
'prompts',
'unconfig',
'vite',
'ws',
'zod',
// node builtins
...builtinModules,
// node builtins with prefix
...builtinModules.map((name) => `node:${name}`),
];
export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
build: {
ssr: true,
lib: {
entry: {
entry: resolve(__dirname, 'src/entry.ts'),
index: resolve(__dirname, 'src/index.ts'),
},
fileName: '[name]',
formats: ['cjs', 'es'],
},
rollupOptions: {
external: (src) => {
const name = src.split('/')[0];
return externalModules.includes(name);
},
},
outDir: 'dist',
emptyOutDir: true,
sourcemap: false,
},
ssr: {
noExternal: true,
},
plugins: [
dts({
include: 'src/**/*.ts',
entryRoot: resolve(__dirname, 'src'),
outputDir: resolve(__dirname, 'dist/typings'),
rollupTypes: true,
}),
],
});