webpack學習筆記 (三) webpack-dev-server外掛程式和HotModuleReplacementPlugin外掛程式使用

來源:互聯網
上載者:User

標籤:打包   參數配置   ntp   llb   sts   不清楚   輸入   message   evel   

 

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 errorwarninginfo or none.

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

 

HotModuleReplacementPlugin 

 (後續補充吧)

webpack學習筆記 (三) webpack-dev-server外掛程式和HotModuleReplacementPlugin外掛程式使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.