feat: 优化网站性能、响应式设计和测试覆盖率
- 更新next.config.ts配置以优化图片和静态资源 - 优化字体加载策略,减少首屏阻塞 - 使用Next.js Image组件替换img标签并实现懒加载 - 重构移动端菜单交互,提升触摸体验 - 新增安全测试和可访问性测试用例 - 修复导航栏滚动定位问题 - 更新部署就绪测试脚本 - 添加相关文档说明优化细节
This commit is contained in:
+33
-2
@@ -1,7 +1,9 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
output: 'export',
|
||||
output: isDev ? undefined : 'export',
|
||||
distDir: 'dist',
|
||||
images: {
|
||||
remotePatterns: [
|
||||
@@ -10,19 +12,48 @@ const nextConfig: NextConfig = {
|
||||
hostname: '**',
|
||||
},
|
||||
],
|
||||
unoptimized: true,
|
||||
formats: ['image/avif', 'image/webp'],
|
||||
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
||||
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
|
||||
dangerouslyAllowSVG: true,
|
||||
contentDispositionType: 'attachment',
|
||||
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
|
||||
minimumCacheTTL: 60,
|
||||
unoptimized: !isDev,
|
||||
},
|
||||
compress: true,
|
||||
poweredByHeader: false,
|
||||
reactStrictMode: true,
|
||||
experimental: {
|
||||
optimizePackageImports: ['lucide-react', 'framer-motion'],
|
||||
optimizeCss: true,
|
||||
},
|
||||
compiler: {
|
||||
removeConsole: process.env.NODE_ENV === 'production',
|
||||
},
|
||||
headers: async () => {
|
||||
return [
|
||||
{
|
||||
source: '/:all*(svg|jpg|jpeg|png|gif|webp|avif)',
|
||||
locale: false,
|
||||
headers: [
|
||||
{
|
||||
key: 'Cache-Control',
|
||||
value: 'public, max-age=31536000, immutable',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
source: '/_next/static/:all*',
|
||||
locale: false,
|
||||
headers: [
|
||||
{
|
||||
key: 'Cache-Control',
|
||||
value: 'public, max-age=31536000, immutable',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user