-
-
Notifications
You must be signed in to change notification settings - Fork 494
/
vite.config.ts
92 lines (87 loc) · 2.67 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
import { resolve } from "path";
import dts from "vite-plugin-dts";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import tsconfigPaths from "vite-tsconfig-paths";
import { configDefaults, defineConfig } from "vitest/config";
import { copyFileSync } from "node:fs";
export default defineConfig({
plugins: [
tsconfigPaths(),
dts({
rollupTypes: true,
afterBuild: () => {
// https://github.com/dolanmiu/docx/pull/2883
// To pass publint - `npx publint@latest`
copyFileSync("dist/index.d.ts", "dist/index.d.cts");
},
}),
nodePolyfills({
exclude: [],
globals: {
Buffer: false,
},
protocolImports: true,
}),
],
resolve: {
alias: {
"@util/": `${resolve(__dirname, "src/util")}/`,
"@export/": `${resolve(__dirname, "src/export")}/`,
"@file/": `${resolve(__dirname, "src/file")}/`,
"@shared": `${resolve(__dirname, "src/shared")}`,
},
},
build: {
minify: false,
target: "es2015",
lib: {
entry: [resolve(__dirname, "src/index.ts")],
name: "docx",
fileName: (d) => {
if (d === "umd") {
return "index.umd.cjs";
}
if (d === "cjs") {
return "index.cjs";
}
if (d === "es") {
return "index.mjs";
}
if (d === "iife") {
return "index.iife.js";
}
return "unknown";
},
formats: ["iife", "es", "cjs", "umd"],
},
outDir: resolve(__dirname, "dist"),
commonjsOptions: {
include: [/node_modules/],
},
},
test: {
environment: "jsdom",
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
thresholds: {
statements: 100,
branches: 99.68,
functions: 100,
lines: 100,
},
exclude: [
...configDefaults.exclude,
"**/dist/**",
"**/demo/**",
"**/docs/**",
"**/scripts/**",
"**/src/**/index.ts",
"**/src/**/types.ts",
"**/*.spec.ts",
],
},
include: ["**/src/**/*.spec.ts", "**/packages/**/*.spec.ts"],
exclude: [...configDefaults.exclude, "**/build/**", "**/demo/**", "**/docs/**", "**/scripts/**"],
},
});