同步發表到驢形筆記
上一篇已經讓express正常運作了,這一篇要開始讓伺服器自動更新與重啟,這篇非常適合連假後的禮拜一,很短(可不可以不要上班= =
這邊要運用到之前學過的nodemon讓伺服器自動重啟
npm i nodemon --save-d
然後修改"package.json"更改腳本指令
package.json
{
"name": "ithome_30day",
"version": "1.0.0",
"description": "IT邦邦忙鐵人賽用git檔案",
"main": "index.js",
"scripts": {
"start": "nodemon dist/index.bundle.js",
"test": "echo \"Error: no test specified\" && exit 1",
"webpack": "webpack -d"
},
略
接著讓webpack在每次檔案修改之後就去自動重新編譯,所以依樣修改腳本指令
{
"name": "ithome_30day",
"version": "1.0.0",
"description": "IT邦邦忙鐵人賽用git檔案",
"main": "index.js",
"scripts": {
"start": "nodemon dist/index.bundle.js",
"test": "echo \"Error: no test specified\" && exit 1",
"webpack": "webpack -d -w"
},
略
這樣每次伺服器檔案修改,伺服器就會自動重新啟動了。這樣webpack的說明就差不多了