@penjc/homepage
Version:
个人主页模板,支持博客、随笔等功能
48 lines (38 loc) • 1.21 kB
JavaScript
/** @type {import('next').NextConfig} */
const isProd = process.env.NODE_ENV === 'production';
const isGithubPages = process.env.GITHUB_PAGES === 'true';
// 尝试读取站点配置
let baseUrl = '';
try {
const { siteConfig } = require('./site.config.ts');
baseUrl = siteConfig.deployment?.baseUrl || '';
} catch (error) {
// 如果 site.config.ts 不存在,使用默认配置
console.warn('Warning: site.config.ts not found, using empty baseUrl');
baseUrl = '';
}
const nextConfig = {
// 启用静态导出
output: 'export',
// 禁用图片优化(静态导出不支持)
images: {
unoptimized: true,
},
// 配置基础路径(只有在 GitHub Pages 部署时才使用 baseUrl)
basePath: isProd && isGithubPages ? baseUrl : '',
// 配置静态资源前缀(只有在 GitHub Pages 部署时才使用 baseUrl)
assetPrefix: isProd && isGithubPages && baseUrl ? `${baseUrl}/` : '',
// 禁用服务端功能
trailingSlash: true,
// 配置构建输出
distDir: '.next',
// 配置 TypeScript
typescript: {
ignoreBuildErrors: false,
},
// 配置 ESLint
eslint: {
ignoreDuringBuilds: false,
},
}
module.exports = nextConfig