mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00

* perf: local file create collection * rename middleware * perf: remove code * feat: next14 * feat: external file dataset * collection tags field * external file dataset doc * fix: ts
98 lines
2.5 KiB
JavaScript
98 lines
2.5 KiB
JavaScript
/** @type {import('next').NextConfig} */
|
|
const { i18n } = require('./next-i18next.config');
|
|
const path = require('path');
|
|
|
|
const nextConfig = {
|
|
i18n,
|
|
output: 'standalone',
|
|
reactStrictMode: process.env.NODE_ENV === 'development' ? false : true,
|
|
compress: true,
|
|
webpack(config, { isServer, nextRuntime }) {
|
|
Object.assign(config.resolve.alias, {
|
|
'@mongodb-js/zstd': false,
|
|
'@aws-sdk/credential-providers': 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']
|
|
},
|
|
{
|
|
test: /\.node$/,
|
|
use: [{ loader: 'nextjs-node-loader' }]
|
|
}
|
|
]),
|
|
exprContextCritical: false,
|
|
unknownContextCritical: false
|
|
};
|
|
|
|
if (!config.externals) {
|
|
config.externals = [];
|
|
}
|
|
|
|
if (isServer) {
|
|
config.externals.push('worker_threads');
|
|
|
|
if (nextRuntime === 'nodejs') {
|
|
// config.output.globalObject = 'self';
|
|
|
|
const oldEntry = config.entry;
|
|
config = {
|
|
...config,
|
|
async entry(...args) {
|
|
const entries = await oldEntry(...args);
|
|
return {
|
|
...entries,
|
|
'worker/htmlStr2Md': path.resolve(
|
|
process.cwd(),
|
|
'../../packages/service/worker/htmlStr2Md/index.ts'
|
|
),
|
|
'worker/countGptMessagesTokens': path.resolve(
|
|
process.cwd(),
|
|
'../../packages/service/worker/tiktoken/countGptMessagesTokens.ts'
|
|
),
|
|
'worker/readFile': path.resolve(
|
|
process.cwd(),
|
|
'../../packages/service/worker/file/read.ts'
|
|
)
|
|
};
|
|
}
|
|
};
|
|
}
|
|
} else {
|
|
config.resolve = {
|
|
...config.resolve,
|
|
fallback: {
|
|
...config.resolve.fallback,
|
|
fs: false
|
|
}
|
|
};
|
|
}
|
|
|
|
config.experiments = {
|
|
asyncWebAssembly: true,
|
|
layers: true
|
|
};
|
|
|
|
return config;
|
|
},
|
|
transpilePackages: ['@fastgpt/*', 'ahooks', '@chakra-ui/*', 'react'],
|
|
experimental: {
|
|
// 指定导出包优化,按需引入包模块
|
|
optimizePackageImports: ['mongoose', 'pg'],
|
|
outputFileTracingRoot: path.join(__dirname, '../../')
|
|
}
|
|
};
|
|
|
|
module.exports = nextConfig;
|