-
-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy pathvite.config.ts
More file actions
84 lines (78 loc) · 1.8 KB
/
vite.config.ts
File metadata and controls
84 lines (78 loc) · 1.8 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
83
84
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react-swc";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { visualizer } from "rollup-plugin-visualizer";
import preserveDirectives from "rollup-preserve-directives";
import { defineConfig, type UserConfig } from "vite";
import dts from "vite-plugin-dts";
import svgr from "vite-plugin-svgr";
const __dirname = dirname(fileURLToPath(import.meta.url));
const libraryConfig: UserConfig = {
build: {
lib: {
entry: resolve(__dirname, "lib/index.ts"),
name: "react-resizable-panels",
fileName: "react-resizable-panels",
formats: ["cjs", "es"]
},
rollupOptions: {
external: ["react", "react-dom", "react/jsx-runtime"]
},
sourcemap: true,
terserOptions: {
compress: {
directives: false
}
}
},
plugins: [react(), dts({ rollupTypes: true }), preserveDirectives()],
publicDir: false
};
const websiteConfig: UserConfig = {
base: "/",
build: {
minify: "terser",
outDir: "docs",
sourcemap: true,
terserOptions: {
format: {
comments: false
}
}
},
plugins: [
react(),
svgr(),
tailwindcss(),
visualizer({
emitFile: true,
filename: "stats.html"
})
],
resolve: {
alias: {
"react-resizable-panels": resolve(__dirname, "lib")
}
}
};
// Allow iPhone to connect to the DEV site using a local IP
if (process.env.NODE_ENV === "development") {
websiteConfig.server = {
host: true,
port: 3000
};
}
let config: UserConfig = {};
switch (process.env.TARGET) {
case "lib": {
config = libraryConfig;
break;
}
default: {
config = websiteConfig;
break;
}
}
// https://vite.dev/config/
export default defineConfig(config);