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 {
vitePlugin as remix,
cloudflareDevProxyVitePlugin as remixCloudflareDevProxy,
} from "@remix-run/dev";
import adapter from "@hono/vite-dev-server/cloudflare";
import serverAdapter from "hono-remix-adapter/vite";
import path from "path";
import { flatRoutes } from "remix-flat-routes";
import { UserConfig, defineConfig, loadEnv } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
const _plugins = [
remixCloudflareDevProxy({
persist: true,
}),
remix({
future: {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
unstable_optimizeDeps: true,
},
ignoredRouteFiles: ["**/*"],
routes: async (defineRoutes) => {
return flatRoutes("routes", defineRoutes);
},
}),
serverAdapter({
adapter,
entry: "server/index.ts",
}),
tsconfigPaths(),
];
// _plugins.unshift(MillionLint.vite());
export default defineConfig((mode) => {
return {
plugins: _plugins,
resolve: {
alias: {
...(mode.mode === "development" && {
postgres: path.resolve(__dirname, "../../node_modules/postgres/src/index.js"),
}),
},
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".css"],
},
ssr: {
target: "node",
noExternal:
mode.mode === "development"
? ["@udecode/plate-math", "katex", "prismjs", "react-tweet", "drizzle-orm"]
: ["@udecode/plate-math", "katex", "prismjs"],
},
css: {
modules: {
scopeBehaviour: "local",
generateScopedName: "[name]__[local]___[hash:base64:5]",
localsConvention: "camelCaseOnly",
},
},
build: {
rollupOptions: {
onwarn(warning, warn) {
if (warning.code === "UNUSED_EXTERNAL_IMPORT") return;
if (warning.code === "IGNORED_BARE_IMPORT") return;
warn(warning);
},
onLog(level, log, handler) {
// @ts-expect-error
if (log.cause?.message?.includes("Can't resolve original location of error.")) return;
handler(level, log);
},
},
},
optimizeDeps: {
include: ["react-tweet"],
},
} satisfies UserConfig;
});
|