forked from Shelf-nu/shelf.nu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
81 lines (80 loc) · 2.39 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import devServer, { defaultOptions } from "@hono/vite-dev-server";
import esbuild from "esbuild";
import { flatRoutes } from "remix-flat-routes";
import { cjsInterop } from "vite-plugin-cjs-interop";
export default defineConfig({
server: {
port: 3000,
// https: {
// key: "./server/dev/key.pem",
// cert: "./server/dev/cert.pem",
// },
// https://github.com/remix-run/remix/discussions/8917#discussioncomment-8640023
warmup: {
clientFiles: [
"./app/entry.client.tsx",
"./app/root.tsx",
"./app/routes/**/*",
],
},
},
// https://github.com/remix-run/remix/discussions/8917#discussioncomment-8640023
optimizeDeps: {
include: ["./app/routes/**/*"],
},
resolve: {
alias: {
".prisma/client/index-browser":
"./node_modules/.prisma/client/index-browser.js",
},
},
plugins: [
cjsInterop({
// List of CJS dependencies that require interop
dependencies: [
"react-microsoft-clarity",
"@markdoc/markdoc",
"react-to-print",
],
}),
devServer({
injectClientScript: false,
entry: "server/index.ts", // The file path of your server.
exclude: [/^\/(app)\/.+/, /^\/@.+$/, /^\/node_modules\/.*/],
}),
remix({
serverBuildFile: "remix.js",
ignoredRouteFiles: ["**/.*"],
routes: async (defineRoutes) => {
return flatRoutes("routes", defineRoutes);
},
buildEnd: async () => {
await esbuild
.build({
alias: { "~": "./app" },
// The final file name
outfile: "build/server/index.js",
// Our server entry point
entryPoints: ["server/index.ts"],
// Dependencies that should not be bundled
// We import the remix build from "../build/server/remix.js", so no need to bundle it again
external: ["./build/server/*"],
platform: "node",
format: "esm",
// Don't include node_modules in the bundle
packages: "external",
bundle: true,
logLevel: "info",
})
.catch((error: unknown) => {
console.error(error);
process.exit(1);
});
},
}),
tsconfigPaths(),
],
});