-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
56 lines (54 loc) · 1.62 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
import { UserConfig, ConfigEnv, defineConfig } from "vite";
import { join } from "path";
import jotaiDebugLabel from "jotai/babel/plugin-debug-label";
import jotaiReactRefresh from "jotai/babel/plugin-react-refresh";
import react from "@vitejs/plugin-react";
const srcRoot = join(__dirname, "src");
export default ({ command }: ConfigEnv): UserConfig => {
// DEV
if (command === "serve") {
return {
base: "/",
publicDir: `${__dirname}/public`,
plugins: [react({ babel: { plugins: [jotaiDebugLabel, jotaiReactRefresh] } })],
alias: {
"/@": srcRoot,
},
build: {
outDir: join(srcRoot, "/out"),
emptyOutDir: true,
rollupOptions: {},
},
server: {
port: process.env.PORT === undefined ? 3000 : +process.env.PORT,
},
optimizeDeps: {
exclude: ["path"],
},
};
}
// PROD
else {
return {
base: `./`,
publicDir: `./public`,
plugins: [],
alias: {
"/@": srcRoot,
},
build: {
outDir: join(srcRoot, "/out"),
emptyOutDir: true,
rollupOptions: {},
},
esbuild: { jsxInject: "import React from 'react'" },
server: {
port: process.env.PORT === undefined ? 3000 : +process.env.PORT,
},
root: "./",
optimizeDeps: {
exclude: ["path"],
},
};
}
};