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

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


The following commit(s) were added to refs/heads/feat/1.3.1/ui by this push:
     new 588b2719 fix: ui bundle size resplit
588b2719 is described below

commit 588b27190e8e6c48087d196baaff4206a5f55ca0
Author: shuai <[email protected]>
AuthorDate: Fri Apr 19 17:29:28 2024 +0800

    fix: ui bundle size resplit
---
 ui/config-overrides.js           | 60 ++++++++++++++++++++--------------------
 ui/src/i18n/init.ts              | 11 ++++----
 ui/src/pages/Questions/index.tsx |  2 +-
 ui/src/utils/localize.ts         |  2 +-
 4 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/ui/config-overrides.js b/ui/config-overrides.js
index b3ff6e8a..4be4efc1 100644
--- a/ui/config-overrides.js
+++ b/ui/config-overrides.js
@@ -52,9 +52,9 @@ module.exports = {
           minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
           chunks: 'initial',
         },
-        i18next: {
-          name: 'i18next',
-          test: /[\/]node_modules[\/](i18next)[\/]/,
+        mix1: {
+          name: 'chunk-mix1',
+          test: /[\/]node_modules[\/](i18next|lodash|marked|next-share)[\/]/,
           filename: 'static/js/[name].[contenthash:8].chunk.js',
           priority: 12,
           reuseExistingChunk: true,
@@ -70,15 +70,15 @@ module.exports = {
           chunks: 'initial',
           reuseExistingChunk: true,
         },
-        lodash: {
-          name: 'lodash',
-          test: /[\/]node_modules[\/](lodash)[\/]/,
-          filename: 'static/js/[name].[contenthash:8].chunk.js',
-          priority: 10,
-          reuseExistingChunk: true,
-          minChunks: 1,
-          chunks: 'initial',
-        },
+        // lodash: {
+        //   name: 'lodash',
+        //   test: /[\/]node_modules[\/](lodash)[\/]/,
+        //   filename: 'static/js/[name].[contenthash:8].chunk.js',
+        //   priority: 10,
+        //   reuseExistingChunk: true,
+        //   minChunks: 1,
+        //   chunks: 'initial',
+        // },
         codemirror: {
           name: 'codemirror',
           test: /[\/]node_modules[\/](codemirror)[\/]/,
@@ -86,24 +86,24 @@ module.exports = {
           reuseExistingChunk: true,
           enforce: true,
         },
-        nextShare: {
-          name: 'next-share',
-          test: /[\/]node_modules[\/](next-share)[\/]/,
-          filename: 'static/js/[name].[contenthash:8].chunk.js',
-          priority: 8,
-          reuseExistingChunk: true,
-          minChunks: 1,
-          chunks: 'initial',
-        },
-        marked: {
-          name: 'marked',
-          test: /[\/]node_modules[\/](marked)[\/]/,
-          filename: 'static/js/[name].[contenthash:8].chunk.js',
-          priority: 7,
-          reuseExistingChunk: true,
-          minChunks: 1,
-          chunks: 'initial',
-        },
+        // nextShare: {
+        //   name: 'next-share',
+        //   test: /[\/]node_modules[\/](next-share)[\/]/,
+        //   filename: 'static/js/[name].[contenthash:8].chunk.js',
+        //   priority: 8,
+        //   reuseExistingChunk: true,
+        //   minChunks: 1,
+        //   chunks: 'initial',
+        // },
+        // marked: {
+        //   name: 'marked',
+        //   test: /[\/]node_modules[\/](marked)[\/]/,
+        //   filename: 'static/js/[name].[contenthash:8].chunk.js',
+        //   priority: 7,
+        //   reuseExistingChunk: true,
+        //   minChunks: 1,
+        //   chunks: 'initial',
+        // },
         reactDom: {
           name: 'react-dom',
           test: /[\/]node_modules[\/](react-dom)[\/]/,
diff --git a/ui/src/i18n/init.ts b/ui/src/i18n/init.ts
index 03f775cb..86188900 100644
--- a/ui/src/i18n/init.ts
+++ b/ui/src/i18n/init.ts
@@ -21,7 +21,7 @@ import { initReactI18next } from 'react-i18next';
 
 import i18next from 'i18next';
 import en_US from '@i18n/en_US.yaml';
-import zh_CN from '@i18n/zh_CN.yaml';
+// import zh_CN from '@i18n/zh_CN.yaml';
 
 import { DEFAULT_LANG, LANG_RESOURCE_STORAGE_KEY } from '@/common/constants';
 import Storage from '@/utils/storage';
@@ -34,9 +34,9 @@ const initResources = {
   en_US: {
     translation: en_US.ui,
   },
-  zh_CN: {
-    translation: zh_CN.ui,
-  },
+  // zh_CN: {
+  //   translation: zh_CN.ui,
+  // },
 };
 
 const storageLang = Storage.get(LANG_RESOURCE_STORAGE_KEY);
@@ -44,8 +44,7 @@ if (
   storageLang &&
   storageLang.resources &&
   storageLang.lng &&
-  storageLang.lng !== 'en_US' &&
-  storageLang.lng !== 'zh_CN'
+  storageLang.lng !== 'en_US'
 ) {
   initResources[storageLang.lng] = {
     translation: storageLang.resources,
diff --git a/ui/src/pages/Questions/index.tsx b/ui/src/pages/Questions/index.tsx
index e0bf27ff..f1b26c18 100644
--- a/ui/src/pages/Questions/index.tsx
+++ b/ui/src/pages/Questions/index.tsx
@@ -53,7 +53,7 @@ const Questions: FC = () => {
     Storage.set(QUESTIONS_ORDER_STORAGE_KEY, curOrder);
   }
   const reqParams: Type.QueryQuestionsReq = {
-    page_size: 20,
+    page_size: 10,
     page: curPage,
     order: curOrder as Type.QuestionOrderBy,
   };
diff --git a/ui/src/utils/localize.ts b/ui/src/utils/localize.ts
index cfebb684..b64473a9 100644
--- a/ui/src/utils/localize.ts
+++ b/ui/src/utils/localize.ts
@@ -133,7 +133,7 @@ const localeDayjs = (langName) => {
 
 export const setupAppLanguage = async () => {
   const lang = getCurrentLang();
-  if (!i18next.getDataByLanguage(lang)) {
+  if (!i18next.getDataByLanguage(lang)?.translation) {
     await addI18nResource(lang);
   }
   localeDayjs(lang);

Reply via email to