webpack-dev-server插件html
webpack-dev-server是webpack官方提供的一個小型Express服務器。使用它能夠爲webpack打包生成的資源文件提供web服務。webpack
webpack-dev-server 主要提供兩個功能:git
HotModuleReplacementPlugin插件github
HotModuleReplacementPlugin主要用於代碼熱替換(具體用途還不清楚,由於沒有研究通透吧)web
1、webpack-dev-server插件說明npm
安裝:json
在cmd中輸入npm webpack-dev-server -g執行;api
啓動:服務器
在cmd中輸入 webpack-dev-server執行;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
.
HotModuleReplacementPlugin
(後續補充吧)