Improve user search and optimize Next.js config
User search in the admin users page now queries the backend instead of filtering on the client, and resets pagination on search. Next.js config adds production compression, removes console logs in production (except error/warn), disables the poweredByHeader, and introduces custom webpack code splitting for better bundle optimization. Updated tsconfig target to ES2020.
This commit is contained in:
@@ -6,6 +6,7 @@ const withBundleAnalyzer = bundleAnalyzer({ enabled: process.env.ANALYZE === 'tr
|
||||
const baseConfig = {
|
||||
output: 'standalone',
|
||||
reactStrictMode: false,
|
||||
compress: process.env.NODE_ENV === 'production',
|
||||
images: {
|
||||
remotePatterns: [
|
||||
{
|
||||
@@ -16,7 +17,6 @@ const baseConfig = {
|
||||
protocol: "https",
|
||||
hostname: "telegram.org",
|
||||
},
|
||||
// Backend API hostname configured via environment variable
|
||||
...(process.env.API_HOSTNAME ? [{
|
||||
protocol: "https",
|
||||
hostname: process.env.API_HOSTNAME,
|
||||
@@ -26,7 +26,6 @@ const baseConfig = {
|
||||
async rewrites() {
|
||||
const apiBaseUrl = process.env.API_BASE_URL;
|
||||
|
||||
// Ensure API_BASE_URL is valid to prevent 500 errors
|
||||
if (!apiBaseUrl || apiBaseUrl === 'undefined') {
|
||||
console.warn('⚠️ API_BASE_URL not set! Set it to your backend domain');
|
||||
console.warn('⚠️ Using localhost fallback - this will fail in production!');
|
||||
@@ -46,8 +45,64 @@ const baseConfig = {
|
||||
},
|
||||
];
|
||||
},
|
||||
experimental: {
|
||||
// serverExternalPackages has been deprecated in Next.js 15
|
||||
compiler: {
|
||||
removeConsole: process.env.NODE_ENV === 'production' ? {
|
||||
exclude: ['error', 'warn'],
|
||||
} : false,
|
||||
},
|
||||
poweredByHeader: false,
|
||||
webpack: (config, { isServer, dev }) => {
|
||||
if (!isServer && !dev) {
|
||||
// Only apply aggressive code splitting in production
|
||||
config.optimization = {
|
||||
...config.optimization,
|
||||
moduleIds: 'deterministic',
|
||||
splitChunks: {
|
||||
chunks: 'all',
|
||||
cacheGroups: {
|
||||
default: false,
|
||||
vendors: false,
|
||||
recharts: {
|
||||
test: /[\\/]node_modules[\\/]recharts[\\/]/,
|
||||
name: 'recharts',
|
||||
chunks: 'all',
|
||||
priority: 30,
|
||||
},
|
||||
radix: {
|
||||
test: /[\\/]node_modules[\\/]@radix-ui[\\/]/,
|
||||
name: 'radix-ui',
|
||||
chunks: 'all',
|
||||
priority: 25,
|
||||
},
|
||||
reactMarkdown: {
|
||||
test: /[\\/]node_modules[\\/]react-markdown[\\/]/,
|
||||
name: 'react-markdown',
|
||||
chunks: 'all',
|
||||
priority: 20,
|
||||
},
|
||||
dateFns: {
|
||||
test: /[\\/]node_modules[\\/]date-fns[\\/]/,
|
||||
name: 'date-fns',
|
||||
chunks: 'all',
|
||||
priority: 15,
|
||||
},
|
||||
framework: {
|
||||
name: 'framework',
|
||||
chunks: 'all',
|
||||
test: /[\\/]node_modules[\\/](react|react-dom|scheduler)[\\/]/,
|
||||
priority: 40,
|
||||
enforce: true,
|
||||
},
|
||||
commons: {
|
||||
name: 'commons',
|
||||
minChunks: 2,
|
||||
priority: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
return config;
|
||||
},
|
||||
onDemandEntries: {
|
||||
maxInactiveAge: 15 * 1000,
|
||||
|
||||
Reference in New Issue
Block a user