-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
46 lines (43 loc) · 1.16 KB
/
vite.config.js
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
import { defineConfig } from "@cyco130/vite";
export default defineConfig((env) => ({
appType: "custom",
experimental: {
skipSsrTransform: true,
},
build: {
rollupOptions: {
input: env.ssrBuild
? { "entry-server": "entry-server.js" }
: { "entry-client": "entry-client.js" },
},
manifest: !env.ssrBuild,
},
plugins: [
{
name: "vite-plugin-node-loader",
apply: "serve",
async configureServer(server) {
// Make the server available globally
global.__vite_dev_server__ = server;
return () => {
server.middlewares.use(async (req, res, next) => {
// This eval is needed to prevent ESBuild to inline this import when bundling the config
const entry = await (0, eval)(
`import("./handler?vavite-entry")`
).then((m) => m.default);
entry(req, res, next);
});
};
},
buildEnd() {
// Remove the server from the global scope
delete global.__vite_dev_server__;
},
config() {
return {
optimizeDeps: { include: [] },
};
},
},
],
}));