-
Notifications
You must be signed in to change notification settings - Fork 9
/
vite.config.ts
44 lines (39 loc) · 1.02 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
import { defineConfig } from "vite";
import reactRefresh from "@vitejs/plugin-react-refresh";
import path from "path";
import typescript from "@rollup/plugin-typescript";
const resolvePath = (str: string) => path.resolve(__dirname, str);
const isProd = process.env.NODE_ENV === "production";
const devConfig = defineConfig({
plugins: [reactRefresh()],
build: {
outDir: "dist-demo",
},
base: "/zustand-middleware-xstate/",
});
const prodConfig = defineConfig({
build: {
lib: {
entry: resolvePath("lib/xstate.ts"),
name: "zustand-middleware-xstate",
fileName: (format) => `xstate.${format}.js`,
},
rollupOptions: {
external: ["zustand", "xstate"],
output: {
globals: {
xstate: "xstate",
},
},
},
},
plugins: [
typescript({
rootDir: resolvePath("lib"),
declaration: true,
declarationDir: resolvePath("dist"),
exclude: resolvePath("node_modules/**"),
}),
],
});
export default isProd ? prodConfig : devConfig;