forked from Forlingham/scash_web_wallet_next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
73 lines (67 loc) · 1.81 KB
/
Copy pathnext.config.js
File metadata and controls
73 lines (67 loc) · 1.81 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const withPWA = require('next-pwa')({
dest: 'public', // Service Worker 和相关文件的输出目录
register: true, // 自动在客户端注册 Service Worker
skipWaiting: true, // 安装后立即激活新的 Service Worker
disable: process.env.NODE_ENV === 'development', // 在开发环境中禁用 PWA,只在生产环境生效
});
/** @type {import('next').NextConfig} */
const nextConfig = {
async rewrites() {
if (process.env.NODE_ENV !== 'production') {
return [
{
source: '/api/:path*',
// destination: 'http://localhost:7020/api/:path*',
destination: 'https://test.scash.network/api/:path*',
},
{
source: '/ext/:path*',
destination: 'https://scash.tv/ext/:path*',
},
]
}
return []
},
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Cache-Control',
value: 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0',
},
],
},
];
},
// 修改开发服务器端口
webpack: (config) => {
return config
},
typescript: {
// !! 警告: 仅用于构建通过,生产环境应移除此配置
// ignoreBuildErrors: true,
},
webpack: (config, { isServer }) => {
// 添加对 WASM 文件的支持
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
}
// 添加 WASM 文件的规则
config.module.rules.push({
test: /\.wasm$/,
type: 'webassembly/async',
})
// 如果是服务端,忽略某些模块
if (isServer) {
config.externals = config.externals || []
config.externals.push({
'tiny-secp256k1': 'tiny-secp256k1'
})
}
return config
},
}
module.exports = withPWA(nextConfig);