Webpack Study Notes (iii) Webpack-dev-server plugin and Hotmodulereplacementplugin plugin use

Source: Internet
Author: User

Webpack-dev-server Plug-in

Webpack-dev-server is a small Express server that is officially provided by Webpack. Use it to provide a Web service for the resource files generated by the Webpack package.

Webpack-dev-server provides two main functions:

    • Service for static files
    • Auto Refresh and Hot swap (HMR)

Hotmodulereplacementplugin Plug-in

Hotmodulereplacementplugin is mainly used for code hot replacement (the specific use is not clear, because there is no research transparent bar)

First, Webpack-dev-server plug-in description

Installation:

Enter NPM webpack-dev-server-g execution in cmd;

Start:

Enter webpack-dev-server execution in CMD;

Additional parameter configuration

Adding Devserver configuration items in Webpack.config.json

The configuration parameters are described below:

  • --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 or IP. 0.0.0.0binds to all hosts.
  • --port <number>: Port.
  • --inline: Embed the Webpack-dev-server runtime into the bundle.
  • --hot: Adds the and switch the server to Hot HotModuleReplacementPlugin mode. Note:make sure you don ' t add HotModuleReplacementPlugin twice.
  • --hot --inlineAlso 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 is combined with --hot ).
  • --https: Serves webpack-dev-server over HTTPS Protocol. Includes a self-signed certificate that's 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 the history API fallback.
  • --client-log-level: Controls the console log messages shown in the browser. Use error , warning , info or none .

Webpack-dev-server For more information, see here

HotModuleReplacementPlugin

(Follow-up supplement)

Webpack Study Notes (iii) Webpack-dev-server plugin and Hotmodulereplacementplugin plugin use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.