Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:hammer: Improve webpack conf

Daniel8bc0449fac0b
diff --git a/app/webpack.config.js b/app/webpack.config.js
index f768f26656..d8211c8091 100644
--- a/app/webpack.config.js
+++ b/app/webpack.config.js
@@ -32,6 +32,30 @@ module.exports = (env, argv) => {
sourcemap: argv.mode !== "production",
}),
],
+ // 把 webpack runtime 提到独立小文件,避免业务码变动连带改变 vendors/common 的 chunkhash
+ runtimeChunk: "single",
+ splitChunks: {
+ chunks: "all",
+ minSize: 20000,
+ cacheGroups: {
+ // 第三方依赖统一进 vendors chunk(dayjs、iconv-lite、@tiptap/* 等)
+ vendors: {
+ test: /[\\/]node_modules[\\/]/,
+ name: "vendors",
+ chunks: "all",
+ priority: 10,
+ },
+ // main 与 window 两入口共享的业务码(constants / layout / protyle / editor / plugin ...),
+ // 提取到 common chunk 以消除两入口约 90% 的重复打包
+ common: {
+ name: "common",
+ chunks: "all",
+ minChunks: 2,
+ priority: 5,
+ reuseExistingChunk: true,
+ },
+ },
+ },
},
module: {
rules: [