-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.mjs
More file actions
42 lines (35 loc) · 1.15 KB
/
next.config.mjs
File metadata and controls
42 lines (35 loc) · 1.15 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
import path from 'node:path'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const transformersEntry = require.resolve('@huggingface/transformers')
const transformersWebEntry = path.join(path.dirname(transformersEntry), 'transformers.web.js')
const nextConfig = {
reactStrictMode: true,
allowedDevOrigins: ['127.0.0.1', 'localhost'],
env: {
NEXT_PUBLIC_E2E_MOCK_RUNTIME: process.env.NEXT_PUBLIC_E2E_MOCK_RUNTIME || '0',
},
webpack: (config, { dev }) => {
const onnxDistDir = path.dirname(require.resolve('onnxruntime-web/webgpu'))
const onnxWebGpuEntry = path.join(
onnxDistDir,
dev ? 'ort.webgpu.min.js' : 'ort.webgpu.min.mjs'
)
config.resolve.alias = {
...config.resolve.alias,
'@huggingface/transformers$': transformersWebEntry,
'onnxruntime-web/webgpu$': onnxWebGpuEntry,
'onnxruntime-node$': false,
'sharp$': false,
}
config.module.rules.push({
test: /onnxruntime-web[\\/]dist[\\/].*\.mjs$/,
type: 'javascript/esm',
resolve: {
fullySpecified: false,
},
})
return config
},
}
export default nextConfig