-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
56 lines (50 loc) · 1.79 KB
/
Copy pathnext.config.ts
File metadata and controls
56 lines (50 loc) · 1.79 KB
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
import type { NextConfig } from "next";
const isServerless = process.env.NEXT_PUBLIC_LEETPROOF_SERVERLESS === "true";
const isFirebase = process.env.NEXT_PUBLIC_DB_PROVIDER === "firebase";
const nextConfig: NextConfig = {
// In serverless mode, produce a fully static site in the `out/` directory.
...(isServerless && {
output: "export",
// GitHub Pages project sites are served from /<repo-name>/.
// Set NEXT_PUBLIC_BASE_PATH=/leetproof (or your repo name) when deploying.
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "",
}),
// Turbopack (Next.js 16 default bundler)
turbopack: {
// When firebase provider is NOT selected, alias firebase packages to an
// empty stub so the build doesn't fail if firebase isn't installed.
resolveAlias: {
...(isFirebase
? {}
: {
"firebase/app": "@/lib/db/firebase-stub",
"firebase/firestore": "@/lib/db/firebase-stub",
"firebase/auth": "@/lib/db/firebase-stub",
}),
// lean4monaco uses Node.js modules in browser (same as vite-plugin-node-polyfills)
path: "path-browserify",
fs: "memfs",
perf_hooks: "./src/lib/perf-hooks-stub.ts",
},
},
// lean4monaco / monaco-editor need transpilation for proper bundling
transpilePackages: ["lean4monaco"],
// Webpack fallback (used with --webpack flag)
webpack: (config) => {
if (!isFirebase) {
config.resolve.alias = {
...config.resolve.alias,
"firebase/app": false,
"firebase/firestore": false,
"firebase/auth": false,
};
}
// lean4monaco uses Node.js `path` module in browser
config.resolve.fallback = {
...config.resolve.fallback,
path: require("path-browserify"),
};
return config;
},
};
export default nextConfig;