-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
82 lines (76 loc) · 2.13 KB
/
vite.config.ts
File metadata and controls
82 lines (76 loc) · 2.13 KB
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
/*
* Copyright (c) 2019-2026 by Brockmann Consult Development team
* Permissions are hereby granted under the terms of the MIT License:
* https://opensource.org/licenses/MIT.
*/
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react-swc";
import dts from "vite-plugin-dts";
import { resolve } from "node:path";
import { globSync } from "glob";
import manifest from "./package.json";
function findFiles(root: string, pattern: string): string[] {
return globSync(`${resolve(__dirname, root)}/${pattern}`).map((path) =>
resolve(__dirname, path),
);
}
const externalModules = [
...Object.keys(manifest.peerDependencies || {}),
...Object.keys(manifest.dependencies || {}),
];
const externalFiles = [...findFiles("src", "**/*.test.*")];
// noinspection JSUnusedGlobalSymbols
export default defineConfig({
plugins: [
react(),
dts({
include: ["src/**/*.ts", "src/**/*.tsx"],
}),
],
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
publicDir: false,
build: {
sourcemap: true,
lib: {
entry: {
chartlets: resolve(__dirname, "src/index.ts"),
"mui-plugin": resolve(__dirname, "src/plugins/mui/index.ts"),
"vega-plugin": resolve(__dirname, "src/plugins/vega/index.ts"),
},
//formats: ["es"],
},
rollupOptions: {
// externalize deps that shouldn't be bundled into the library
external: [/^@mui/, /^react/, ...externalModules, ...externalFiles],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
microdiff: "diff",
react: "React",
"react-dom": "ReactDOM",
"react-vega": "ReactVega",
zustand: "zustand",
},
},
},
},
test: {
globals: true,
environment: "jsdom",
setupFiles: "vitest.setup.ts",
coverage: {
provider: "istanbul",
},
onConsoleLog: (_log: string, _type: "stdout" | "stderr"): false | void => {
const logLevel = process.env.VITE_LOG_LEVEL;
if (!logLevel || logLevel === "OFF") {
return false;
}
},
},
});