We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
HotModuleReplacementPlugin
entry
webpack-hot-middleware/client?path=http://127.0.0.1:9000/__webpack_hmr&noInfo=false&reload=true&quiet=false
webpack-hot-middleware
webpack
watch
node
fs模块的watch
memory-fs
devServer
webpack api
compile
done
hash
ok
reload
HotModuleReplacement.runtime
module.hot.accept()
参考: Advanced-Frontend/Daily-Interview-Question#118
https://zhuanlan.zhihu.com/p/30669007
https://zhuanlan.zhihu.com/p/30623057
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Webpack
的配置中添加HotModuleReplacementPlugin
插件entry
注入热更新代码,用于保证服务端与客户端之间能够通信webpack-hot-middleware
使用的是window.EventSource)webpack
的api对文件系统进行watch
,其本质就是node
中fs模块的watch
,当有文件修改时,webpack
就会对文件进行重新编译打包,然后保存到内存中,用到的库是memory-fs
devServer
通知浏览器端文件发生了改变,并调用webpack api
监听compile
的done
事件,当compile
完成后将编译打包后的新模块hash
值发送到浏览器端hash
的响应来告知是哪个hash的模块,待接收到ok
时执行reload
操作webpack
接收到最新hash
值验证并请求模块代码HotModuleReplacement.runtime
对模块进行热更新,具体包括模块匹配,模块替换等操作module.hot.accept()
完成热更新参考:
Advanced-Frontend/Daily-Interview-Question#118
https://zhuanlan.zhihu.com/p/30669007
https://zhuanlan.zhihu.com/p/30623057
The text was updated successfully, but these errors were encountered: