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的热更新使用及原理分析(是如何做到在不刷新浏览器的前提下更新页面的) #85

Open
GGXXMM opened this issue Jan 12, 2021 · 0 comments
Labels
webpack webpack knowledge

Comments

@GGXXMM
Copy link
Owner

GGXXMM commented Jan 12, 2021

webpack的热更新使用

1、webpack-dev-server + HotModuleReplacementPlugin

2、webpack-dev-middleware(使用较多)

热更新原理分析

image

Webpack Compile:将JS编译成Bundle
bundle.js:构建输出的文件
Bundle Server:提供文件在浏览器的访问
HRM Server:将热更新的文件输出给HRM Runtime
HRM Runtime:会被注入到浏览器,更新文件的变化

热更新过程描述:

  1. 当修改了一个或多个文件;
  2. 文件系统接收更改并通知webpack;
  3. webpack重新编译构建一个或多个模块,并通知HRM服务器进行更新;
  4. HRM Server使用websocket通知HRM Runtime需要更新,HRM Runtime注入浏览器,更新文件的变化。

参考:https://juejin.cn/post/6844904008432222215

@GGXXMM GGXXMM added the webpack webpack knowledge label Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
webpack webpack knowledge
Projects
None yet
Development

No branches or pull requests

1 participant