-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
80 lines (77 loc) · 2.08 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
import path from "node:path";
import mdx from "@mdx-js/rollup";
import { vitePlugin as remix } from "@remix-run/dev";
import esbuild from "esbuild";
import rehypeKatex from "rehype-katex";
import remarkFrontmatter from "remark-frontmatter";
import remarkMath from "remark-math";
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
import { defineConfig } from "vite";
import envOnly from "vite-env-only";
// vite-tsconfig-paths is too late to resolve the alias
const alias = {
"@": path.resolve("app"),
"@styles": path.resolve("styled-system"),
} as const;
export default defineConfig({
assetsInclude: [/\/old\//],
build: {
cssMinify: "lightningcss",
},
server: {
port: 3000,
proxy: {
"/api/assets": {
target: process.env.API_BASE,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, "/"),
},
},
warmup: {
clientFiles: [
"./app/entry.client.tsx",
"./app/root.tsx",
"./app/routes/**/*",
],
},
},
optimizeDeps: {
include: ["./app/routes/**/*"],
},
resolve: {
alias,
},
plugins: [
envOnly(),
mdx({
remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter, remarkMath],
rehypePlugins: [rehypeKatex],
}),
remix({
serverBuildFile: "remix.js",
buildEnd: async () => {
await esbuild
.build({
alias,
// 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);
});
},
}),
],
});