-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathnext.config.js
63 lines (56 loc) · 1.61 KB
/
next.config.js
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
60
61
62
// const isProd = process.env.NODE_ENV === 'production'
const isProd = false;
const bundleAnalyzer = require('@next/bundle-analyzer')
const withBundleAnalyzer = bundleAnalyzer({
enabled: false,
openAnalyzer: true,
})
module.exports = withBundleAnalyzer({
swcMinify: true,
crossOrigin: 'anonymous',
reactStrictMode: false,
env: {
STATIC_URL: isProd ? STATIC_URL : "http://localhost:3000",
},
// typescript: {
// ignoreBuildErrors: true,
// },
// webpack: (config) => {
// config.externals = [...config.externals, { canvas: 'canvas' }];
// return config;
// },
// experimental: {
// serverActions: {
// allowedOrigins: []
// },
// },
// async redirects() {
// return [
// {
// source: "/home",
// destination: "/",
// permanent: false,
// }]
// }
typescript: {
ignoreBuildErrors: true,
},
output: 'export',
// 禁用图像优化,因为它需要 Next.js 服务器
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (isServer) {
// 在服务器端构建时忽略 API 路由
config.externals = config.externals || [];
config.externals.push((context, request, callback) => {
if (request.startsWith('pages/api/') || request.startsWith('app/api/')) {
return callback(null, `commonjs ${request}`);
}
callback();
});
}
return config;
},
})