forked from starbeamjs/starbeam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
72 lines (66 loc) · 1.69 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
import { defineConfig } from "vitest/config";
const BUNDLED_EXTERNAL_PACKAGES = [
"stacktracey",
"as-table",
"printable-characters",
"get-source",
"data-uri-to-buffer",
"source-map",
];
const EXTERNAL_PACKAGES = ["react", "react-dom"];
export default defineConfig({
optimizeDeps: {
disabled: true,
},
esbuild: {},
build: {
lib: {
entry: "./packages/bundle/src/vanilla.ts",
formats: ["es", "cjs"],
fileName: (format) =>
format === "cjs" ? "starbeam.cjs" : "starbeam.mjs",
},
minify: false,
target: "esnext",
rollupOptions: {
input: {
"starbeam.js": "./packages/bundle/src/vanilla.ts",
"starbeam-react.js": "./packages/bundle/src/react.ts",
},
external: (id, from) => {
if (id.startsWith(".") || id.startsWith("/")) {
return false;
} else if (id.startsWith("@starbeam")) {
return false;
} else if (BUNDLED_EXTERNAL_PACKAGES.includes(id)) {
return false;
} else if (EXTERNAL_PACKAGES.includes(id)) {
return true;
} else {
console.warn(`Unexpected external package: ${id}`, { from });
return true;
}
},
output: [
{
dir: "./dist",
entryFileNames: "[name].[format]",
chunkFileNames: "[name].shared.[format]",
format: "es",
},
{
dir: "./dist",
entryFileNames: "[name].[format]",
chunkFileNames: "[name].shared.[format]",
format: "cjs",
},
],
},
},
test: {
include: ["**/*.spec.ts"],
exclude: ["**/node_modules/**"],
// threads: false,
// allowOnly: true,
},
});