This is an automated email from the ASF dual-hosted git repository.

shuai pushed a commit to branch fix/ui-split-chunks
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit 1823a54c00f34b6f6b6787962ad2b101ff46cab5
Author: shuai <[email protected]>
AuthorDate: Tue May 7 11:55:22 2024 +0800

    fix: optimize split-chunks
---
 ui/config-overrides.js | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/ui/config-overrides.js b/ui/config-overrides.js
index 40e0e8a1..18237a1f 100644
--- a/ui/config-overrides.js
+++ b/ui/config-overrides.js
@@ -44,47 +44,45 @@ module.exports = {
       minChunks: 2,
       cacheGroups: {
         automaticNamePrefix: 'chunk',
-        components: {
-          test: /[\\/]components[\\/]/,
-          name: 'components',
-          priority: 14,
-          reuseExistingChunk: true,
-          minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
-          chunks: 'initial',
-        },
         mix1: {
+          test: (module, chunks) => {
+            return (
+              module.resource &&
+              (module.resource.includes('components') ||
+                /\/node_modules\/react-bootstrap\//.test(module.resource))
+            );
+          },
           name: 'chunk-mix1',
-          test: /[\/]node_modules[\/](i18next|lodash|marked|next-share)[\/]/,
           filename: 'static/js/[name].[contenthash:8].chunk.js',
-          priority: 12,
+          priority: 14,
           reuseExistingChunk: true,
-          minChunks: 1,
+          minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
           chunks: 'initial',
         },
         mix2: {
           name: 'chunk-mix2',
-          test: /[\/]node_modules[\/](@remix-run|@restart|axios|diff)[\/]/,
+          test: /[\/]node_modules[\/](i18next|lodash|marked|next-share)[\/]/,
           filename: 'static/js/[name].[contenthash:8].chunk.js',
-          priority: 11,
+          priority: 13,
           reuseExistingChunk: true,
           minChunks: 1,
           chunks: 'initial',
         },
-        reactBootstrap: {
-          name: 'react-bootstrap',
-          test: /[\/]node_modules[\/](react-bootstrap)[\/]/,
+        mix3: {
+          name: 'chunk-mix3',
+          test: /[\/]node_modules[\/](@remix-run|@restart|axios|diff)[\/]/,
           filename: 'static/js/[name].[contenthash:8].chunk.js',
-          priority: 11,
+          priority: 12,
+          reuseExistingChunk: true,
           minChunks: 1,
           chunks: 'initial',
-          reuseExistingChunk: true,
         },
         codemirror: {
           name: 'codemirror',
           test: /[\/]node_modules[\/](\@codemirror)[\/]/,
-          priority: 9,
+          priority: 10,
           reuseExistingChunk: true,
-          minChunks: 1,
+          minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
           chunks: 'initial',
           enforce: true,
         },
@@ -93,7 +91,7 @@ module.exports = {
           test: /[\/]node_modules[\/](\@lezer)[\/]/,
           priority: 9,
           reuseExistingChunk: true,
-          minChunks: 1,
+          minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
           chunks: 'initial',
           enforce: true,
         },
@@ -101,7 +99,7 @@ module.exports = {
           name: 'react-dom',
           test: /[\/]node_modules[\/](react-dom)[\/]/,
           filename: 'static/js/[name].[contenthash:8].chunk.js',
-          priority: 7,
+          priority: 8,
           reuseExistingChunk: true,
           chunks: 'all',
           enforce: true,

Reply via email to