Files
cunkebao_v3/Cunkebao/next.config.js
笔记本里的永平 521a3f1269 feat: 本次提交更新内容如下
开始迁移工作台了,有好多问题
2025-07-08 08:59:58 +08:00

99 lines
2.8 KiB
JavaScript
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.

const path = require('path');
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
experimental: {
serverComponentsExternalPackages: ['axios'],
},
images: {
domains: [
'localhost',
'ckbapi.quwanzhi.com',
'blob.v0.dev',
'hebbkx1anhila5yf.public.blob.vercel-storage.com'
],
formats: ['image/webp', 'image/avif'],
unoptimized: true,
},
env: {
CUSTOM_KEY: process.env.CUSTOM_KEY,
},
async redirects() {
return [
{
source: '/scenarios/new',
destination: '/scenarios/new/basic',
permanent: false,
},
];
},
async rewrites() {
const apiBase = process.env.NEXT_PUBLIC_API_BASE_URL;
if (!apiBase) {
console.warn('环境变量 NEXT_PUBLIC_API_BASE_URL 未设置rewrites 不生效');
return [];
}
return [
{
source: '/api/proxy/:path*',
destination: `${apiBase}/:path*`,
},
];
},
async headers() {
return [
{
source: '/api/:path*',
headers: [
{ key: 'Access-Control-Allow-Origin', value: '*' },
{ key: 'Access-Control-Allow-Methods', value: 'GET, POST, PUT, DELETE, OPTIONS' },
{ key: 'Access-Control-Allow-Headers', value: 'Content-Type, Authorization' },
],
},
];
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.resolve.alias = {
...config.resolve.alias,
'@': path.resolve(__dirname),
};
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
};
return config;
},
output: 'standalone',
compress: true,
poweredByHeader: false,
generateEtags: true,
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
trailingSlash: false,
distDir: '.next',
staticPageGenerationTimeout: 60,
...(process.env.NODE_ENV === 'development' && {
onDemandEntries: {
maxInactiveAge: 25 * 1000,
pagesBufferLength: 2,
},
}),
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
};
if (process.env.ANALYZE === 'true') {
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: true,
});
module.exports = withBundleAnalyzer(nextConfig);
} else {
module.exports = nextConfig;
}