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

webpack 中 chunkhash 和 contenthash 有什么区别 #6

Open
fengzilong opened this issue Dec 6, 2019 · 0 comments
Open

webpack 中 chunkhash 和 contenthash 有什么区别 #6

fengzilong opened this issue Dec 6, 2019 · 0 comments
Labels

Comments

@fengzilong
Copy link
Owner

fengzilong commented Dec 6, 2019

简言之:chunkhash 无法实现 Long Term Caching

一个 chunk 可能包含不同类型的资源,最终会产出多个文件,比如 JS / CSS,如果使用 chunkhash,当该 chunk 中的 css 变化时,会导致整体的 chunkhash 发生变化,从而 js 的文件名也会受到影响,缓存失效

而 contenthash 是针对文件级别的,当一个文件本身的内容不发生变化时,hash 值就不会发生变化

题外话:为什么有了 contenthash,还需要 chunkhash 呢?

chunkhash 可能有特殊的应用场景,更多的是出于向下兼容的考虑

参考:
webpack/webpack.js.org#2096

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

No branches or pull requests

1 participant