-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
81 lines (78 loc) · 2.83 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
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import nodeExternals from "rollup-plugin-node-externals";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import { resolve } from "path";
export default defineConfig(({ mode }) => {
if (mode === "production" || mode === "development") {
return {
plugins: [
nodePolyfills({
exclude: ["crypto"]
}),
dts({
include: ["src"],
outDir: "dist/",
rollupTypes: true,
copyDtsFiles: true,
}),
],
build: {
emptyOutDir: false,
lib: {
entry: [
resolve(__dirname, "src/index.ts"),
resolve(__dirname, "src/policy/Policy.ts"),
resolve(__dirname, "src/policy/loader/Loader.ts"),
resolve(__dirname, "src/generator/Generator.ts"),
resolve(__dirname, "src/rule/Rule.ts"),
],
formats: ["es"],
},
target: "esnext",
rollupOptions: {
external: [
"crypto"
],
output: {
manualChunks: (id) => {
if (id.includes("zxcvbn")) {
if (id.includes("@zxcvbn-ts/language-de")) {
return "zxcvbn-de";
}
if (id.includes("@zxcvbn-ts/language-en")) {
return "zxcvbn-en";
}
if (id.includes("@zxcvbn-ts/language-common")) {
return "zxcvbn-common";
}
return `zxcvbn`;
}
if (id.includes("/ajv/")) {
return "ajv";
}
if (id.endsWith("/wordlist.ts")) {
return "wordlist";
}
if (id.includes("/yaml/")) {
return "yaml";
}
},
},
},
},
};
}
return {
plugins: [nodeExternals()],
build: {
outDir: "./dist/bin",
lib: {
entry: resolve(__dirname, "src/cli/cli.ts"),
formats: ["es"],
fileName: "cli",
},
target: "node21",
},
};
});