/* eslint-disable @typescript-eslint/no-var-requires */ /** @type {import('next').NextConfig} */ const path = require('path'); const withLess = require('next-with-less'); const withTM = require('next-transpile-modules')([ '@arco-design/web-react', '@arco-themes/react-arco-pro', '@xyflow/react', '@xyflow/system', '@uiw/react-codemirror' ]); const setting = require('./src/settings.json'); const target = process.env.NEXT_PUBLIC_DEV_SERVER_HOST; module.exports = withLess( withTM({ // 静态导出配置 output: 'export', distDir: 'dist', // 指定输出目录为 dist 文件夹 lessLoaderOptions: { lessOptions: { modifyVars: { 'arcoblue-6': setting.themeColor } } }, webpack: (config) => { config.module.rules.push({ test: /\.svg$/, use: ['@svgr/webpack'] }); config.resolve.alias['@/assets'] = path.resolve( __dirname, './src/public/assets' ); config.resolve.alias['@'] = path.resolve(__dirname, './src'); // 解决 react/jsx-runtime 找不到的问题 config.resolve.alias['react/jsx-runtime'] = path.resolve(__dirname, './node_modules/react/jsx-runtime.js'); config.resolve.alias['react/jsx-dev-runtime'] = path.resolve(__dirname, './node_modules/react/jx-dev-runtime.js'); return config; }, async redirects() { return [ { source: '/', destination: '/login', permanent: true } ]; }, // 添加代理配置 async rewrites() { return [ { source: '/api/:path*', destination: `${target}/api/:path*` // api代理 } ]; }, pageExtensions: ['tsx'] }) );