forked from OikuraAmatsume/mapannai-public
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
44 lines (42 loc) · 1.3 KB
/
next.config.js
File metadata and controls
44 lines (42 loc) · 1.3 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
/** @type {import('next').NextConfig} */
const withPWA = require('next-pwa')({
dest: 'public',
disable: process.env.NODE_ENV === 'development',
register: true,
skipWaiting: true,
runtimeCaching: [
// OSM 地图瓦片:NetworkFirst,只缓存成功响应,失败直接穿透
{
urlPattern: /^https:\/\/tile\.openstreetmap\.org\/.+/,
handler: 'NetworkFirst',
options: {
cacheName: 'osm-tiles',
expiration: {
maxEntries: 256,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 天
},
cacheableResponse: {
statuses: [200], // 只缓存 200,绝不缓存失败响应
},
},
},
],
})
const nextConfig = {
// 启用 standalone 输出模式,用于 Docker 优化
output: 'standalone',
images: {
// 从环境变量获取图片域名
domains: process.env.NEXT_PUBLIC_IMAGE_DOMAINS?.split(',') || [
'mapannai-1253047877.cos.ap-chongqing.myqcloud.com'
],
},
webpack: (config) => {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
};
return config;
},
}
module.exports = withPWA(nextConfig)