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

lesson2中的例子并没有实现热更新 #3

Open
lisleyang opened this issue Dec 12, 2017 · 0 comments
Open

lesson2中的例子并没有实现热更新 #3

lisleyang opened this issue Dec 12, 2017 · 0 comments

Comments

@lisleyang
Copy link

更改的时候,仍然会由webpack-dev-server进行自动刷新,而不是HotModuleReplacePlugin的不刷新。

“要使HMR功能生效,还需要做一件事情,就是要在应用热替换的模块或者根模块里面加入允许热替换的代码。否则,热替换不会生效,还是会重刷整个页面。下面是摘自webpack在github上docs的原话:
A module can only be updated if you "accept" it. So you need to module.hot.accept the module in the parents or the parents of the parents... I. e. a Router is a good place or a subview.

具体的代码是:

if(module.hot)
    module.hot.accept();
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

1 participant