-
-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathnext.config.js
More file actions
48 lines (46 loc) · 1.29 KB
/
next.config.js
File metadata and controls
48 lines (46 loc) · 1.29 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
/** @type {import('next').NextConfig} */
const isRestrictedMode = process.env.NEXT_PUBLIC_RESTRICTED_MODE === 'true'
const nextConfig = {
reactStrictMode: true,
assetPrefix: process.env.BASE_PATH || '',
basePath: process.env.BASE_PATH || '',
trailingSlash: true,
...(!isRestrictedMode && {
outputFileTracingRoot: __dirname,
}),
// Cloudflare Workers向け
...(isRestrictedMode && {
serverExternalPackages: ['openai', 'xxhash-wasm'],
// Cloudflare Workers向け: 不要ファイルをファイルトレースから除外
outputFileTracingExcludes: {
'*': [
'./node_modules/canvas/**/*',
'./public/**/*',
'./scripts/**/*',
'./logs/**/*',
'./reports/**/*',
'./coverage/**/*',
],
},
}),
env: {
NEXT_PUBLIC_BASE_PATH: process.env.BASE_PATH || '',
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
...(config.resolve.fallback ?? {}),
fs: false,
}
}
// Cloudflare Workers向け: ネイティブモジュールを空モジュールに置換
if (isServer && isRestrictedMode) {
config.resolve.alias = {
...(config.resolve.alias ?? {}),
canvas: false,
}
}
return config
},
}
module.exports = nextConfig