build: drop next-pwa and switch to default Next 16 build
This commit is contained in:
+14
-18
@@ -1,26 +1,22 @@
|
||||
import type { NextConfig } from "next";
|
||||
import withPWAInit from "@ducanh2912/next-pwa";
|
||||
|
||||
/**
|
||||
* PWA 开关:仅在 production 启用。
|
||||
* - dev 模式 SW 会干扰 HMR
|
||||
* - 测试/构建(vitest)也跳过
|
||||
*/
|
||||
const isProd = process.env.NODE_ENV === "production";
|
||||
|
||||
const withPWA = withPWAInit({
|
||||
// SW 输出目录(Next.js 静态资源根)
|
||||
dest: "public",
|
||||
// 仅 production 注入;dev 不启用避免 HMR 干扰
|
||||
disable: !isProd,
|
||||
// 缓存策略:API 不缓存(业务 token 实时敏感),静态资源用默认 Workbox 策略
|
||||
// 不显式声明 runtimeCaching,走 Workbox 默认(precache + NetworkFirst HTML + CacheFirst 静态)
|
||||
});
|
||||
|
||||
/**
|
||||
* Next.js 16 临时绕过 `/_global-error` prerender 的 workStore bug
|
||||
* 标记根 layout 不参与静态预渲染(global-error 会在请求时渲染)
|
||||
* https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
|
||||
*
|
||||
* 默认部署模型:`.next/` + `public/` + `next start`(或 Vercel 零配置)
|
||||
* - `pnpm build` 产出 .next/(含 build manifest / chunks / 路由表 / 静态预渲染)
|
||||
* - 脚本侧:scripts/deploy/_deploy_lib.sh 同步 .next/ + public/
|
||||
* - 服务器启动:`cd <path> && next start -H 0.0.0.0 -p 3000`
|
||||
* 或用 PM2:`pm2 start "next start" --name cozsweet`
|
||||
*
|
||||
* 已知 trade-off:@ducanh2912/next-pwa 是 webpack-only 插件,与 Turbopack 不兼容。
|
||||
* 本轮按用户指令采用"默认构建",**移除了 next-pwa 插件**(`public/manifest.json` +
|
||||
* `public/favicon.ico` 仍由 Next.js metadata 加载;install prompt 仍由
|
||||
* `usePwaInstall` hook 监听 `beforeinstallprompt` 浏览器 API 提供)。
|
||||
* Service Worker 暂不再自动生成;如未来需要,请改用 Next 16 原生 PWA 方案
|
||||
* (`src/app/manifest.ts` + 手写 `public/sw.js` + client `useEffect` 注册)。
|
||||
*/
|
||||
const nextConfig: NextConfig = {
|
||||
experimental: {
|
||||
@@ -29,4 +25,4 @@ const nextConfig: NextConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
export default withPWA(nextConfig);
|
||||
export default nextConfig;
|
||||
|
||||
Reference in New Issue
Block a user