標籤:打包 參數配置 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 error, warning, info or none.
webpack-dev-server相關介紹請參見這裡
HotModuleReplacementPlugin
(後續補充吧)
webpack學習筆記 (三) webpack-dev-server外掛程式和HotModuleReplacementPlugin外掛程式使用