Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

子项目有一行配置文件没看懂 config.optimization.splitChunks(false) #13

Closed
qiaokeli111 opened this issue Mar 16, 2021 · 1 comment

Comments

@qiaokeli111
Copy link

config.optimization.splitChunks(false)
请问这行代码干什么,我以为是关闭组件拆分,可是为什么要关闭,能不能解释下

@zh-rocco
Copy link
Collaborator

@qiaokeli111

关闭 splitChunks
image

开启 splitChunks
image

splitChunks 会将项目中的公共依赖提取到 chunk-vendors.xxxxxxxx.js 文件中,项目运行我们需要先加载 chunk-vendors.xxxxxxxx.js,然后再加载项目的入口文件(main.js)。然而子项目中我们需要暴露出去一个独立且完整的 JS 文件,所以就关闭了 splitChunks,将 chunk-vendors.xxxxxxxx.js 的内容合并至 main.js

补充:splitChunks 介绍

Since webpack v4, the CommonsChunkPlugin was removed in favor of optimization.splitChunks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants