![you dont know js 知乎 you dont know js 知乎](https://pic2.zhimg.com/v2-8f78a49690a6735fabf2c2d0ab9cdbf6_720w.jpg)
In the process of modifying the setNum method, it was found that the page was refreshed directly, and it did not achieve the expected hot update operation. By modifying this method, the page can be directly hot updated. SetNum method is called once every second to update the value of the num, and then modify the text of div#app setNum method is in the num.js file. Here because we need to operate on the DOM, in order to facilitate our direct use of jQuery (yyds), the jQuery CDN is introduced into the HTML file. Ĭonst HtmlWebpackPlugin = require('html-webpack-plugin')Īfter the configuration is complete, we can start to create a new file according to the following directory structure. When starting the development service, configure the devServe attribute in the webpack configuration file to start the hot update mode. "build": "webpack build -mode production -config " "dev": "webpack serve -mode development -config ",
![you dont know js 知乎 you dont know js 知乎](https://farseerfc.me/zhs/why-linus-torvalds-undermine-gplv3.png)
Webpack serve -mode development -config // pkg.json
![you dont know js 知乎 you dont know js 知乎](https://pic4.zhimg.com/80/v2-f00c6ddb1ae5dfc93c1cc29c37997913_1440w.jpg)
Then, we need to figure out that after webpack version the service needs to be started through the webpack CLI, and the packaged command and the command to start the development service are provided.
#YOU DONT KNOW JS 知乎 INSTALL#
We first install some packages we need: npm i webpack webpack-cli -D Today's article will explore the secrets of webpack hot update. Students who have used webpack should know that there is a particularly useful "hot update" that can push the code to the browser without refreshing the page.