-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnext.config.ts
More file actions
57 lines (55 loc) · 1.58 KB
/
next.config.ts
File metadata and controls
57 lines (55 loc) · 1.58 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
57
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
outputFileTracingExcludes: {
"*": [
"node_modules/onnxruntime-node/**/*",
"node_modules/@huggingface/transformers/**/*",
"node_modules/@xenova/transformers/**/*",
"node_modules/@img/**/*",
"node_modules/sharp/**/*",
],
},
async headers() {
return [
{
source: "/api/:path*",
headers: [
{ key: "Access-Control-Allow-Origin", value: "*" },
{ key: "Access-Control-Allow-Methods", value: "GET, POST, OPTIONS" },
{ key: "Access-Control-Allow-Headers", value: "Content-Type, Authorization" },
],
},
];
},
// Next.js 16 uses Turbopack by default
turbopack: {
resolveAlias: {
// web-tree-sitter conditionally imports Node-only modules;
// stub them out for browser bundles so the bundler can resolve them.
"fs/promises": { browser: "./src/lib/fs-browser-stub.ts" },
module: { browser: "./src/lib/fs-browser-stub.ts" },
},
},
webpack: (config, { isServer }) => {
if (!isServer) {
// Disable Node-only packages for the browser bundle
config.resolve.alias = {
...config.resolve.alias,
"onnxruntime-node$": false,
"sharp$": false,
};
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
module: false,
};
}
// Allow .wasm files to be imported
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
};
return config;
},
};
export default nextConfig;