-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
30 lines (28 loc) · 821 Bytes
/
Copy pathvite.config.ts
File metadata and controls
30 lines (28 loc) · 821 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
import { defineConfig } from "vite";
/** 仅打包 app/ 源码;node_modules 与 Node 内置模块在运行时解析 */
function isExternal(id: string): boolean {
if (id.startsWith("node:")) return true;
if (id.startsWith(".") || id.startsWith("/")) return false;
if (/^[A-Za-z]:[\\/]/.test(id)) return false;
if (!id.includes("node_modules") && /[\\/]app[\\/]/.test(id)) return false;
if (id.startsWith("app/") || id.startsWith("app\\")) return false;
return true;
}
export default defineConfig({
build: {
target: "node20",
ssr: true,
outDir: "dist",
sourcemap: true,
minify: false,
emptyOutDir: true,
rollupOptions: {
input: "app/index.ts",
output: {
entryFileNames: "index.js",
format: "es",
},
external: isExternal,
},
},
});