@@ -9,22 +9,77 @@ jiti('./env');
99
1010// const backendUrl = new URL(process.env.NEXT_PUBLIC_BACKEND_URL);
1111
12- const backendUrl = new URL ( process . env . BACKEND_URL ) ;
13- const platformUrl = new URL ( process . env . NEXT_PUBLIC_PLATFORM_URL ) ; // Use NEXT_PUBLIC_ for client-side access
12+ const backendUrl = new URL ( process . env . BACKEND_URL || 'http://localhost:8000' ) ;
13+ const platformUrl = new URL ( process . env . NEXT_PUBLIC_PLATFORM_URL || 'http://localhost:3000' ) ;
1414
15- const withNextIntl = createNextIntlPlugin ( ) ;
15+ const withNextIntl = createNextIntlPlugin ( './i18n.ts' ) ;
1616const nextConfig = withNextIntl ( {
1717 transpilePackages : [ 'opub-ui' ] ,
18+
19+ // Performance optimizations
20+ experimental : {
21+ optimizePackageImports : [ 'opub-ui' , 'echarts' , 'lucide-react' , '@tabler/icons-react' ] ,
22+ webpackBuildWorker : true ,
23+ optimizeCss : true ,
24+ } ,
25+
26+ // Compiler optimizations
27+ compiler : {
28+ removeConsole : process . env . NODE_ENV === 'production' ,
29+ } ,
30+
31+ // Webpack optimizations
32+ webpack : ( config , { dev, isServer } ) => {
33+ // Optimize for development speed
34+ if ( dev ) {
35+ config . watchOptions = {
36+ poll : false ,
37+ ignored : [ '**/node_modules' , '**/.git' , '**/.next' ] ,
38+ } ;
39+ }
40+
41+ // Production bundle optimizations
42+ if ( ! dev && ! isServer ) {
43+ config . optimization = config . optimization || { } ;
44+ config . optimization . splitChunks = config . optimization . splitChunks || { } ;
45+ config . optimization . splitChunks . cacheGroups = {
46+ ...( config . optimization . splitChunks . cacheGroups || { } ) ,
47+ echarts : {
48+ name : 'echarts' ,
49+ test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] e c h a r t s / ,
50+ chunks : 'all' ,
51+ priority : 20 ,
52+ } ,
53+ icons : {
54+ name : 'icons' ,
55+ test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] ( @ t a b l e r \/ i c o n s - r e a c t | l u c i d e - r e a c t ) / ,
56+ chunks : 'all' ,
57+ priority : 15 ,
58+ } ,
59+ ui : {
60+ name : 'opub-ui' ,
61+ test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] o p u b - u i / ,
62+ chunks : 'all' ,
63+ priority : 10 ,
64+ } ,
65+ } ;
66+ }
67+
68+ return config ;
69+ } ,
70+
1871 images : {
1972 remotePatterns : [
2073 {
2174 protocol : backendUrl . protocol . slice ( 0 , - 1 ) ,
2275 hostname : backendUrl . hostname ,
76+ port : backendUrl . port || '' ,
77+ pathname : '/**' ,
2378 } ,
2479 {
25- protocol : platformUrl . protocol . replace ( ':' , '' ) ,
80+ protocol : platformUrl . protocol . slice ( 0 , - 1 ) ,
2681 hostname : platformUrl . hostname ,
27- port : platformUrl . port || '' , // empty string if no port
82+ port : platformUrl . port || '' ,
2883 pathname : '/**' ,
2984 } ,
3085 ] ,
@@ -47,7 +102,12 @@ export default withSentryConfig(
47102 // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
48103
49104 // Upload a larger set of source maps for prettier stack traces (increases build time)
50- widenClientFileUpload : true ,
105+ widenClientFileUpload : process . env . NODE_ENV === 'production' ,
106+
107+ // Disable source map upload in development for speed
108+ sourcemaps : {
109+ disable : process . env . NODE_ENV === 'development' ,
110+ } ,
51111
52112 // Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
53113 // This can increase your server load as well as your hosting bill.
@@ -67,5 +127,5 @@ export default withSentryConfig(
67127 // https://vercel.com/docs/cron-jobs
68128 automaticVercelMonitors : true ,
69129 } ,
70- process . env . SENTRY_FEATURE_ENABLED
130+ process . env . SENTRY_FEATURE_ENABLED === 'true'
71131) ;
0 commit comments