-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathvite.sdk-components.config.ts
More file actions
41 lines (38 loc) · 991 Bytes
/
vite.sdk-components.config.ts
File metadata and controls
41 lines (38 loc) · 991 Bytes
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
import { defineConfig } from "vite";
import { existsSync } from "node:fs";
import path from "node:path";
const hasPrivateFolders = existsSync(
path.join(process.cwd(), "private-src", "README.md")
);
const isBareImport = (id: string) =>
id.startsWith("@") || id.includes(".") === false;
export default defineConfig({
build: {
lib: {
entry: [
hasPrivateFolders ? "private-src/components.ts" : "src/components.ts",
"src/metas.ts",
"src/hooks.ts",
"src/templates.ts",
],
formats: ["es"],
},
rollupOptions: {
external: isBareImport,
output: [
{
preserveModules: true,
preserveModulesRoot: "src",
dir: "lib",
},
hasPrivateFolders
? {
preserveModules: true,
preserveModulesRoot: "private-src",
dir: "lib",
}
: undefined,
].filter((output) => output !== undefined),
},
},
});