-
Notifications
You must be signed in to change notification settings - Fork 99
/
next.config.mjs
59 lines (53 loc) · 1.1 KB
/
next.config.mjs
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
import fs from "node:fs/promises";
import path from "node:path";
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
after: true,
},
async headers() {
return [
{
source: "/(.*)",
headers: [
{
key: "Cross-Origin-Opener-Policy",
value: "same-origin",
},
{
key: "Cross-Origin-Embedder-Policy",
value: "require-corp",
},
],
},
];
},
};
export default nextConfig;
async function copyFiles() {
try {
await fs.access("public/");
} catch {
await fs.mkdir("public/", { recursive: true });
}
const wasmFiles = (
await fs.readdir("node_modules/onnxruntime-web/dist/")
).filter((file) => path.extname(file) === ".wasm");
await Promise.all([
fs.copyFile(
"node_modules/@ricky0123/vad-web/dist/vad.worklet.bundle.min.js",
"public/vad.worklet.bundle.min.js"
),
fs.copyFile(
"node_modules/@ricky0123/vad-web/dist/silero_vad.onnx",
"public/silero_vad.onnx"
),
...wasmFiles.map((file) =>
fs.copyFile(
`node_modules/onnxruntime-web/dist/${file}`,
`public/${file}`
)
),
]);
}
copyFiles();