mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 00:26:37 +08:00
[优化] 环境分离
This commit is contained in:
@@ -1,13 +1,32 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
output: 'export',
|
||||
pageExtensions: ['ts', 'tsx'],
|
||||
images: {
|
||||
unoptimized: true,
|
||||
},
|
||||
eslint: {
|
||||
dirs: ['app', 'components', 'features', 'hooks', 'lib', 'store', 'tests', 'types'],
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
const devBackendUrl =
|
||||
process.env.NEXT_DEV_BACKEND_URL?.replace(/\/+$/, '') || 'http://127.0.0.1:3000';
|
||||
const enableDevProxy = process.env.NEXT_DEV_PROXY === 'true';
|
||||
|
||||
export default function createNextConfig() {
|
||||
const nextConfig = {
|
||||
output: 'export',
|
||||
pageExtensions: ['ts', 'tsx'],
|
||||
images: {
|
||||
unoptimized: true,
|
||||
},
|
||||
eslint: {
|
||||
dirs: ['app', 'components', 'features', 'hooks', 'lib', 'store', 'tests', 'types'],
|
||||
},
|
||||
};
|
||||
|
||||
if (!enableDevProxy) {
|
||||
return nextConfig;
|
||||
}
|
||||
|
||||
return {
|
||||
...nextConfig,
|
||||
async rewrites() {
|
||||
return [
|
||||
{
|
||||
source: '/api/:path*',
|
||||
destination: `${devBackendUrl}/api/:path*`,
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"postbuild": "node scripts/prepare-static-export.mjs",
|
||||
"start": "next start",
|
||||
"start": "NEXT_DEV_PROXY=true next dev -p 3001",
|
||||
"start:prod": "next start",
|
||||
"lint": "eslint . --max-warnings=0",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run",
|
||||
|
||||
Reference in New Issue
Block a user