Files
test1/next.config.ts
2026-03-20 07:33:46 +00:00

44 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { NextConfig } from 'next';
import fs from 'fs';
import path from 'path';
import dotenv from 'dotenv';
// 加载 .env 到 process.env内部会用 dotenv.populate 注入)
dotenv.config({ path: '.env', override: true });
let projectId = '';
// 尝试从根目录 .project 读取 project_id / user_id 注入到环境变量
try {
const projectPath = path.join(process.cwd(), '.project');
const raw = fs.readFileSync(projectPath, 'utf8');
const data = JSON.parse(raw) as {
project_id?: string;
};
// 直接复用 dotenv.populate把 .project 内容也注入到 process.env
projectId = data?.project_id ?? '';
} catch {
// 没有 .project 或解析失败时静默忽略,保持兼容
}
const nextConfig: NextConfig = {
reactStrictMode: false,
turbopack: {},
typescript: {
ignoreBuildErrors: true,
},
env: {
PROJECT_ID: projectId,
},
serverExternalPackages: [
'discord.js',
'@discordjs/ws',
'@discordjs/rest',
'dingtalk-stream',
'ws',
],
};
export default nextConfig;