-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
50 lines (46 loc) · 1.32 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
import "dotenv/config";
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import tailwindcss from "@tailwindcss/vite";
import { resolve } from "node:path";
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const isSSR = command === "build" && mode === "ssr";
const PORT = Number.parseInt(env.VITE_PORT || "6996", 10);
return {
root: "./",
base: "/",
plugins: [vue(), tailwindcss()],
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
define: {
__VUE_PROD_DEVTOOLS__: false,
__VUE_OPTIONS_API__: true,
},
server: {
port: PORT,
strictPort: true,
cors: true,
hmr: true,
},
build: {
outDir: resolve(__dirname, isSSR ? "dist/server" : "dist/client"),
emptyOutDir: !isSSR, // чтобы при сборке SSR не терлась client-сборка
ssr: isSSR,
manifest: !isSSR,
ssrManifest: isSSR,
rollupOptions: {
input: isSSR ? resolve(__dirname, "src/client/entry-server.ts") : resolve(__dirname, "index.html"),
output: {
entryFileNames: "[name].js",
},
},
},
ssr: {
noExternal: ["vue", "@vue/server-renderer", "vue-router", "vue-i18n", "pinia"],
},
};
});