-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
60 lines (58 loc) · 1.43 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
import { defineConfig, UserConfig } from "vite";
import dtsPlugin from "vite-plugin-dts";
export function viteConfig(
config: Partial<UserConfig> & {
entry: Record<string, string> | string[] | string;
}
) {
return defineConfig({
plugins: [
dtsPlugin({
entryRoot: "./src",
outDir: "./lib/types",
include: ["src/**/*.ts", "src/**/*.tsx"],
exclude: ["**/__tests__", "**/example"],
}),
...(config?.plugins || []),
],
resolve: {
preserveSymlinks: true,
},
build: {
outDir: "lib",
minify: false,
reportCompressedSize: true,
...config?.build,
terserOptions: {
compress: false,
mangle: false,
keep_classnames: true,
...config?.build?.terserOptions,
},
rollupOptions: {
preserveEntrySignatures: "allow-extension",
cache: false,
...config?.build?.rollupOptions,
external: [
...((config?.build?.rollupOptions?.external || []) as string[]),
],
},
lib: {
name: "Genshi",
formats: ["es", "cjs"],
fileName:
typeof config.entry === "object"
? (format, entryName) =>
`${entryName}/index.${format == "es" ? "js" : format}`
: undefined,
...config?.build?.lib,
entry: config.entry,
},
},
});
}
export default viteConfig({
entry: {
index: "",
},
});