mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-07 01:02:55 +08:00
aaa7d17ef1
* feat: encapsulate logger (#6535) * feat: encapsulate logger * update engines --------- Co-authored-by: archer <545436317@qq.com> * next config * dev shell * Agent sandbox (#6532) * docs: switch to docs layout and apply black theme (#6533) * feat: add Gemini 3.1 models - Add gemini-3.1-pro-preview (released February 19, 2026) - Add gemini-3.1-flash-lite-preview (released March 3, 2026) Both models support: - 1M context window - 64k max response - Vision - Tool choice * docs: switch to docs layout and apply black theme - Change layout from notebook to docs - Update logo to icon + text format - Apply fumadocs black theme - Simplify global.css (keep only navbar and TOC styles) - Fix icon components to properly accept className props - Add mobile text overflow handling - Update Node engine requirement to >=20.x * doc * doc * lock * fix: ts * doc * doc --------- Co-authored-by: archer <archer@archerdeMac-mini.local> Co-authored-by: archer <545436317@qq.com> * Doc (#6493) * cloud doc * doc refactor * doc move * seo * remove doc * yml * doc * fix: tsconfig * fix: tsconfig * sandbox version (#6497) * sandbox version * add sandbox log * update lock * fix * fix: sandbox * doc * add console * i18n * sandbxo in agent * feat: agent sandbox * lock * feat: sandbox ui * sandbox check exists * env tempalte * doc * lock * sandbox in chat window * sandbox entry * fix: test * rename var * sandbox config tip * update sandbox lifecircle * update prompt * rename provider test * sandbox logger * yml --------- Co-authored-by: Archer <archer@fastgpt.io> Co-authored-by: archer <archer@archerdeMac-mini.local> * perf: sandbox error tip * Add sandbox limit and fix some issue (#6550) * sandbox in plan * fix: some issue * fix: test * editor default path * fix: comment * perf: sandbox worksapce * doc * perf: del sandbox * sandbox build * fix: test * fix: pr comment --------- Co-authored-by: Ryo <whoeverimf5@gmail.com> Co-authored-by: Archer <archer@fastgpt.io> Co-authored-by: archer <archer@archerdeMac-mini.local>
164 lines
4.1 KiB
TypeScript
164 lines
4.1 KiB
TypeScript
import type { NextConfig } from 'next';
|
|
import path from 'path';
|
|
import withBundleAnalyzerInit from '@next/bundle-analyzer';
|
|
import withRspack from 'next-rspack';
|
|
|
|
const withBundleAnalyzer = withBundleAnalyzerInit({ enabled: process.env.ANALYZE === 'true' });
|
|
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
|
|
const nextConfig: NextConfig = {
|
|
basePath: process.env.NEXT_PUBLIC_BASE_URL,
|
|
i18n: {
|
|
defaultLocale: 'en',
|
|
locales: ['en', 'zh-CN', 'zh-Hant'],
|
|
localeDetection: false
|
|
},
|
|
output: 'standalone',
|
|
// 关闭 strict mode,避免第三方库的双重渲染问题
|
|
reactStrictMode: !isDev,
|
|
productionBrowserSourceMaps: false,
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: '/((?!chat/share$).*)',
|
|
headers: [
|
|
{
|
|
key: 'X-Frame-Options',
|
|
value: 'DENY'
|
|
},
|
|
{
|
|
key: 'X-Content-Type-Options',
|
|
value: 'nosniff'
|
|
},
|
|
{
|
|
key: 'X-XSS-Protection',
|
|
value: '1; mode=block'
|
|
},
|
|
{
|
|
key: 'Referrer-Policy',
|
|
value: 'strict-origin-when-cross-origin'
|
|
},
|
|
{
|
|
key: 'Permissions-Policy',
|
|
value: 'geolocation=(self), microphone=(self), camera=(self)'
|
|
}
|
|
]
|
|
}
|
|
];
|
|
},
|
|
|
|
webpack(config, { isServer, dev }) {
|
|
config.ignoreWarnings = [
|
|
...(config.ignoreWarnings || []),
|
|
{
|
|
module: /@scalar\/api-reference-react/,
|
|
message: /autoprefixer/
|
|
},
|
|
{
|
|
module: /any-promise[\\/]register\.js$/,
|
|
message: /Critical dependency: the request of a dependency is an expression/
|
|
},
|
|
{
|
|
module: /bullmq[\\/]dist[\\/](cjs|esm)[\\/]classes[\\/]child-processor\.js$/,
|
|
message: /Critical dependency: the request of a dependency is an expression/
|
|
}
|
|
];
|
|
|
|
Object.assign(config.resolve!.alias, {
|
|
'@mongodb-js/zstd': false,
|
|
'@aws-sdk/credential-providers': false,
|
|
'gcp-metadata': false,
|
|
snappy: false,
|
|
aws4: false,
|
|
'mongodb-client-encryption': false,
|
|
kerberos: false,
|
|
'supports-color': false,
|
|
'bson-ext': false,
|
|
'pg-native': false
|
|
});
|
|
|
|
config.module = {
|
|
...config.module,
|
|
rules: (config.module?.rules || []).concat([
|
|
{
|
|
test: /\.svg$/i,
|
|
issuer: /\.[jt]sx?$/,
|
|
use: ['@svgr/webpack']
|
|
}
|
|
]),
|
|
exprContextCritical: false,
|
|
unknownContextCritical: false
|
|
};
|
|
|
|
if (!config.externals) {
|
|
config.externals = [];
|
|
}
|
|
|
|
if (isServer) {
|
|
(config.externals as string[]).push('@node-rs/jieba');
|
|
}
|
|
|
|
config.experiments = {
|
|
asyncWebAssembly: true,
|
|
layers: true
|
|
};
|
|
|
|
if (isDev && !isServer) {
|
|
config.devtool = 'cheap-module-source-map';
|
|
|
|
config.watchOptions = {
|
|
...config.watchOptions,
|
|
ignored: [
|
|
'**/node_modules',
|
|
'**/.git',
|
|
'**/dist',
|
|
'**/coverage',
|
|
'../../packages/**/node_modules',
|
|
'../../packages/**/dist',
|
|
'**/.next',
|
|
'**/out'
|
|
],
|
|
// 减少轮询频率,降低 CPU 和内存占用
|
|
poll: 1000,
|
|
aggregateTimeout: 300
|
|
};
|
|
}
|
|
|
|
return config;
|
|
},
|
|
transpilePackages: ['@modelcontextprotocol/sdk', 'ahooks'],
|
|
serverExternalPackages: [
|
|
'mongoose',
|
|
'pg',
|
|
'bullmq',
|
|
'@zilliz/milvus2-sdk-node',
|
|
'tiktoken',
|
|
'@opentelemetry/api-logs'
|
|
],
|
|
// 优化大库的 barrel exports tree-shaking
|
|
experimental: {
|
|
optimizePackageImports: [
|
|
'@chakra-ui/react',
|
|
'@chakra-ui/icons',
|
|
'lodash',
|
|
'date-fns',
|
|
'ahooks',
|
|
'framer-motion',
|
|
'@emotion/react',
|
|
'@emotion/styled'
|
|
],
|
|
// 按页面拆分 CSS chunk,减少首屏 CSS 体积
|
|
cssChunking: 'strict',
|
|
// 减少内存占用
|
|
memoryBasedWorkersCount: true
|
|
},
|
|
outputFileTracingRoot: path.join(__dirname, '../../')
|
|
};
|
|
|
|
const configWithPluginsExceptWithRspack = withBundleAnalyzer(nextConfig);
|
|
|
|
export default isDev
|
|
? withRspack(configWithPluginsExceptWithRspack)
|
|
: configWithPluginsExceptWithRspack;
|