From 6c509a6b5499e49ec91b30c924d70d442988705a Mon Sep 17 00:00:00 2001 From: taDuc Date: Thu, 4 Jun 2026 10:21:23 +0700 Subject: [PATCH] perf: optimize bundle and load times via dynamic CSS imports, Webpack vendor chunking, and conditional map loading.(peak male content) --- next.config.ts | 34 ++++++- src/uhm/components/preview/MapPlaceholder.tsx | 90 +------------------ .../components/preview/PreviewMapShell.tsx | 20 +++++ .../preview/PublicPreviewClientPage.tsx | 39 ++++++-- .../preview/PublicPreviewWrapper.tsx | 84 +++++++++++------ src/uhm/components/wiki/PublicWikiSidebar.tsx | 6 +- 6 files changed, 147 insertions(+), 126 deletions(-) diff --git a/next.config.ts b/next.config.ts index 916db6c..78c4b29 100644 --- a/next.config.ts +++ b/next.config.ts @@ -27,11 +27,43 @@ const nextConfig: NextConfig = { ], }, output: 'standalone', - webpack(config) { + webpack(config, { isServer }) { config.module.rules.push({ test: /\.svg$/, use: ["@svgr/webpack"], }); + + if (!isServer) { + // Split heavy third-party vendor libraries into their own dedicated chunks + config.optimization.splitChunks.cacheGroups = { + ...config.optimization.splitChunks.cacheGroups, + maplibre: { + test: /[\\/]node_modules[\\/]maplibre-gl[\\/]/, + name: "maplibre", + chunks: "all", + priority: 40, + }, + quill: { + test: /[\\/]node_modules[\\/](react-quill-new|quill|quill-blot-formatter)[\\/]/, + name: "quill", + chunks: "all", + priority: 35, + }, + charts: { + test: /[\\/]node_modules[\\/](apexcharts|react-apexcharts)[\\/]/, + name: "charts", + chunks: "all", + priority: 30, + }, + calendar: { + test: /[\\/]node_modules[\\/]@fullcalendar[\\/]/, + name: "calendar", + chunks: "all", + priority: 25, + }, + }; + } + return config; }, diff --git a/src/uhm/components/preview/MapPlaceholder.tsx b/src/uhm/components/preview/MapPlaceholder.tsx index a83e903..f2d421a 100644 --- a/src/uhm/components/preview/MapPlaceholder.tsx +++ b/src/uhm/components/preview/MapPlaceholder.tsx @@ -3,98 +3,10 @@ import React from "react"; interface MapPlaceholderProps { - isLoaderOnly?: boolean; onEnter?: () => void; } -export default function MapPlaceholder({ isLoaderOnly = true, onEnter }: MapPlaceholderProps) { - if (isLoaderOnly) { - return ( -
- {/* Background Image */} - {/* eslint-disable-next-line @next/next/no-img-element */} - Map Loading Placeholder - - {/* Dark overlay & Spinner */} -
-
-