-
Notifications
You must be signed in to change notification settings - Fork 18
/
vite.config.ts
99 lines (93 loc) · 2.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
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
/// <reference types="vitest" />
import { defineConfig } from "vite";
import viteTsConfigPaths from "vite-tsconfig-paths";
import dts from "vite-plugin-dts";
import { joinPathFragments } from "@nx/devkit";
import { camelCase } from "lodash-es";
import { viteStaticCopy } from "vite-plugin-static-copy";
//vite config for simple iso packages
const conf = ({
name,
dir,
testEnvironment
}: {
testEnvironment?: string;
name: string;
dir: string;
}) =>
defineConfig(({ command }) => ({
cacheDir: `../../node_modules/.vite/${name}`,
plugins: [
dts({
entryRoot: "src",
tsconfigPath: joinPathFragments(dir, "tsconfig.json")
}),
viteTsConfigPaths({
root: "../../"
}),
...(command === "build"
? [
// noBundlePlugin({ copy: "**/*.css" }),
viteStaticCopy({
targets: [
{
src: "./src",
dest: "."
},
{
src: "./README.md",
dest: "."
}
]
})
]
: [])
],
esbuild: {
keepNames: true,
minifyIdentifiers: false,
minifySyntax: false
},
// Uncomment this if you are using workers.
// worker: {
// plugins: [
// viteTsConfigPaths({
// root: '../../',
// }),
// ],
// },
// Configuration for building your library.
// See: https://vitejs.dev/guide/build.html#library-mode
build: {
minify: false,
target: "es2015",
emptyOutDir: true,
outDir: `../../dist/${name}`,
lib: {
// Could also be a dictionary or array of multiple entry points.
entry: "src/index.js",
name,
fileName: "index",
// Change this to the formats you want to support.
// Don't forgot to update your package.json as well.
formats: ["es", "cjs", "umd"]
},
rollupOptions: {
// External packages that should not be bundled into your library.
external: [],
output: {
name: camelCase(name)
}
}
},
test: {
globals: true,
cacheDir: "../../node_modules/.vitest",
environment: testEnvironment || "node",
include: [
"src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
"test/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"
]
}
}));
export default conf;