Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: optimize the configuration of setWebpackOptimizationSplitChunks #809 #787

shuaifd9d432d10c8
diff --git a/ui/config-overrides.js b/ui/config-overrides.js
index 19698173..9d1a3a7a 100644
--- a/ui/config-overrides.js
+++ b/ui/config-overrides.js
@@ -44,27 +44,11 @@ module.exports = {
minChunks: 2,
cacheGroups: {
automaticNamePrefix: 'chunk',
- components: {
- test: /[\\/]components[\\/]/,
- name: 'components',
- priority: 13,
- minChunks: 2,
- reuseExistingChunk: true,
- enforce: true,
- },
- commons: {
- test: /[\\/]common[\\/]/,
- name: 'common',
- priority: 12,
- minChunks: 2,
- reuseExistingChunk: true,
- enforce: true,
- },
i18next: {
name: 'i18next',
test: /[\/]node_modules[\/](i18next)[\/]/,
filename: 'static/js/[name].[contenthash:8].chunk.js',
- priority: 11,
+ priority: 12,
reuseExistingChunk: true,
minChunks: 1,
chunks: 'initial',
@@ -73,11 +57,20 @@ module.exports = {
name: 'react-bootstrap',
test: /[\/]node_modules[\/](react-bootstrap)[\/]/,
filename: 'static/js/[name].[contenthash:8].chunk.js',
- priority: 10,
+ priority: 11,
minChunks: 1,
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',
+ },
codemirror: {
name: 'codemirror',
test: /[\/]node_modules[\/](codemirror)[\/]/,
@@ -103,6 +96,15 @@ module.exports = {
minChunks: 1,
chunks: 'initial',
},
+ reactDom: {
+ name: 'react-dom',
+ test: /[\/]node_modules[\/](react-dom)[\/]/,
+ filename: 'static/js/[name].[contenthash:8].chunk.js',
+ priority: 7,
+ reuseExistingChunk: true,
+ chunks: 'all',
+ enforce: true,
+ },
nodesAsync: {
name: 'chunk-nodesAsync',
test: /[\/]node_modules[\/]/,
diff --git a/ui/template/header.html b/ui/template/header.html
index 85425674..75c696f9 100644
--- a/ui/template/header.html
+++ b/ui/template/header.html
@@ -54,7 +54,9 @@
href="{{.siteinfo.Branding.SquareIcon}}"
data-rh="true"
/>
- <script defer="defer" src="{{.scriptPath}}"></script>
+ {{range $path := .scriptPath}}
+ <script defer="defer" src="{{$path}}"></script>
+ {{end}}
{{if $.siteinfo.JsonLD }}{{ .siteinfo.JsonLD | templateHTML}}{{end}}
</head>