日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

webpack学习笔记 (三) webpack-dev-server插件和HotModuleReplacementPlugin插件使用

發布時間:2025/5/22 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 webpack学习笔记 (三) webpack-dev-server插件和HotModuleReplacementPlugin插件使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

webpack-dev-server插件

webpack-dev-server是webpack官方提供的一個小型Express服務器。使用它可以為webpack打包生成的資源文件提供web服務。

webpack-dev-server 主要提供兩個功能:

  • 為靜態文件提供服務
  • 自動刷新和熱替換(HMR)

HotModuleReplacementPlugin插件

HotModuleReplacementPlugin主要用于代碼熱替換(具體用途還不清楚,因為沒有研究通透吧)

?

一、webpack-dev-server插件說明

安裝:

在cmd中輸入npm?webpack-dev-server -g執行;

啟動:

在cmd中輸入 webpack-dev-server執行;

?

額外參數配置

在webpack.config.json中增加devServer配置項

配置參數說明如下:

  • --content-base <file/directory/url/port>: base path for the content.
  • --quiet: don’t output anything to the console.
  • --no-info: suppress boring information.
  • --colors: add some colors to the output.
  • --no-colors: don’t use colors in the output.
  • --compress: use gzip compression.
  • --host <hostname/ip>: hostname or IP.?0.0.0.0?binds to all hosts.
  • --port <number>: port.
  • --inline: embed the?webpack-dev-server?runtime into the?bundle.
  • --hot: adds the?HotModuleReplacementPlugin?and switch the server to?hot mode. Note: make sure you don’t add?HotModuleReplacementPlugin?twice.
  • --hot --inline?also adds the?webpack/hot/dev-server?entry.
  • --public: overrides the host and port used in?--inline?mode for the client (useful for a VM or Docker).
  • --lazy: no watching, compiles on request (cannot be combined with?--hot).
  • --https: serves?webpack-dev-server?over HTTPS Protocol. Includes a self-signed certificate that is used when serving the requests.
  • --cert,?--cacert,?--key: Paths the certificate files.
  • --open: opens the url in default browser (for webpack-dev-server versions > 2.0).
  • --history-api-fallback: enables support for history API fallback.
  • --client-log-level: controls the console log messages shown in the browser. Use?error,?warning,?info?or?none.

webpack-dev-server相關介紹請參見這里

?

HotModuleReplacementPlugin?

?(后續補充吧)

轉載于:https://www.cnblogs.com/sunflowerGIS/p/6821792.html

總結

以上是生活随笔為你收集整理的webpack学习笔记 (三) webpack-dev-server插件和HotModuleReplacementPlugin插件使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。