fonts-vault/next.config.ts
bo.yu 19b371e610 chore: initialize project with Next.js app structure and tooling
- Add Next.js application with app router and API routes for brands, categories, fonts, styles, and sync management
- Set up authentication system with NextAuth configuration and protected routes
- Create admin dashboard with management interfaces for brands, categories, fonts, and styles
- Implement database layer with Drizzle ORM and SQLite with migration files
- Add public pages for font browsing, documentation, and login functionality
- Configure development tools including ESLint, Prettier, Husky pre-commit hooks, and lint-staged
- Set up TypeScript configuration with strict type checking and path aliases
- Create reusable UI component library using shadcn/ui and Radix primitives
- Implement service layer for business logic (brands, categories, fonts, styles, sync, CSS generation)
- Add utility functions for authentication, error handling, logging, and performance monitoring
- Configure Next.js with custom middleware for request handling and routing
- Set up testing infrastructure with Vitest and test files for admin and docs pages
- Add project documentation including implementation summaries and API guides
- Configure build tools with PostCSS and Tailwind CSS for styling
- Initialize database with seed data and connection utilities
- Add environment configuration and public assets (favicon, icons, manifest)
2025-11-26 16:44:20 +08:00

90 lines
1.9 KiB
TypeScript

import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
// Webpack 配置
webpack: (config) => {
// 排除 LICENSE 文件
config.module.rules.push({
test: /LICENSE$/,
type: 'asset/source',
});
return config;
},
// 图片优化配置
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**.aliyuncs.com',
pathname: '/**',
},
{
protocol: 'https',
hostname:
process.env.NEXT_PUBLIC_FONT_STATIC_URL?.replace('https://', '') ||
'wenfeng-fonts.oss-cn-guangzhou.aliyuncs.com',
pathname: '/**',
},
],
formats: ['image/avif', 'image/webp'],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
minimumCacheTTL: 60 * 60 * 24 * 365, // 1 year
},
// 实验性功能
experimental: {
// 优化包导入
optimizePackageImports: ['@/components/ui', 'lucide-react'],
},
// 编译优化
compiler: {
removeConsole:
process.env.NODE_ENV === 'production'
? {
exclude: ['error', 'warn'],
}
: false,
},
// 性能优化
poweredByHeader: false,
compress: true,
// 静态资源缓存
async headers() {
return [
{
source: '/fonts/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/_next/static/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/_next/image/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
];
},
};
export default nextConfig;