- shadcn/ui 标准化:废弃纸感令牌,统一 bg-background/text-foreground 等 - Tailwind v4 + @theme inline,移除 tailwind.config.js - React 19 use() + Suspense 流式渲染,首屏骨架秒出 - 三级错误边界:Route → Section → Widget 层层兜底 - 错误上报:useErrorReport → sendBeacon → /api/log mock 端点 - 三层安全边界:L1 角色门禁 / L2 权限点门禁 / L3 数据范围 - 权限位图 base36 压缩:67 权限点 → ~14 字符,JWT 体积减少 ≥ 99% - notify 统一 Toast 封装,禁止业务直接 import sonner - PluginBoundary 替代 PluginLoader(错误边界 + Suspense + Skeleton 三件套) 验证:typecheck 0 错误 / lint 0 错误 / build 6 路由生成成功
69 lines
1.9 KiB
JavaScript
69 lines
1.9 KiB
JavaScript
/**
|
||
* Next.js 配置(v2.1 M8 + v0.2 Tailwind v4 + Next 16 Turbopack)
|
||
*
|
||
* 角色:插件化仪表盘宿主(单 Next.js App Router · 单 Docker)
|
||
* - output: standalone(单容器部署)
|
||
* - transpilePackages: @edu/* workspace 包
|
||
* - 反向代理:/api/v1/* → api-gateway :8080(JWT 校验 + 注入 x-user-id/x-user-role)
|
||
* - GraphQL 查询走 apollo-router :3000(M8 验收点,由 Apollo Client 直连)
|
||
*
|
||
* Next 16 默认 Turbopack:
|
||
* - turbopack.resolveExtensions 处理 ESM 包 .js 后缀导入源码 TS 文件的映射
|
||
* - webpack 配置保留作为 fallback(--webpack flag 时生效)
|
||
*
|
||
* 关联:portal-shell spec §2、project_rules §3.2
|
||
*/
|
||
|
||
/** @type {import('next').NextConfig} */
|
||
const nextConfig = {
|
||
reactStrictMode: true,
|
||
output: "standalone",
|
||
transpilePackages: [
|
||
"@edu/ui-components",
|
||
"@edu/ui-tokens",
|
||
"@edu/hooks",
|
||
"@edu/contracts",
|
||
"@edu/shared-ts",
|
||
],
|
||
experimental: {
|
||
serverActions: { bodySizeLimit: "2mb" },
|
||
},
|
||
// Turbopack 配置(Next 16 默认):处理 ESM 包 .js 后缀导入源码 .ts/.tsx 文件
|
||
turbopack: {
|
||
resolveExtensions: [
|
||
".ts",
|
||
".tsx",
|
||
".js",
|
||
".jsx",
|
||
".mjs",
|
||
".cjs",
|
||
".json",
|
||
],
|
||
},
|
||
// Webpack 配置(fallback,使用 --webpack flag 时生效)
|
||
webpack(config) {
|
||
config.resolve = config.resolve || {};
|
||
config.resolve.extensionAlias = {
|
||
...config.resolve.extensionAlias,
|
||
".js": [".ts", ".tsx", ".js"],
|
||
};
|
||
return config;
|
||
},
|
||
async rewrites() {
|
||
const gateway =
|
||
process.env.API_GATEWAY_URL || "http://localhost:8080";
|
||
return [
|
||
{
|
||
source: "/api/v1/:path*",
|
||
destination: `${gateway}/api/v1/:path*`,
|
||
},
|
||
{
|
||
source: "/api/auth/:path*",
|
||
destination: `${gateway}/api/v1/iam/:path*`,
|
||
},
|
||
];
|
||
},
|
||
};
|
||
|
||
export default nextConfig;
|