Webpack Study (iii) Webpack-dev-server cannot automatically refresh the problem

Source: Internet
Author: User

Use Webpack-dev-server to encounter problems that cannot be automatically refreshed by the browser;

Here are some points to note:

1.webpack-dev-server does not read the configuration of your webpack.config.js output!!

You're in webpack.config.js. The configuration output property is used when you use Webpack to pack, and it doesn't work for webpack-dev-server.

2.webpack-dev-server packaged production files are not added to your project directory!!

The file name that is packaged by default is Bundle.js and does not really appear in your project directory, presumably to be stored in your own environment

Automatic refresh configuration method (inline mode):

I'm used to the idea of adding a package.json inside a project.

"Scripts": {     "start": "Webpack-dev-server--inline--content-base."   }

This allows the use of the NPM Start command to start the inline mode and, of course, the specific input webpack-dev-server command

The key is that your index.html is the HTML file in your project portal that references this bundle.js file that needs to be referenced directly under the root directory!

<body>    <div id= "app" ></div><script type= "Text/javascript" src= "Bundle.js" ></script ></body>

Cannot refer to your webpack configuration of the Bundle.js file directory, webpack configuration of this bundle.js file, only after you manually pack Webpack will not change!

The summary is: Webpack inside the configuration of the bundle.js need to be manually packaged to change the directory can be designated by you! Webpack-dev-server Automated Automatic Packaging is the development environment of the bundle.js, packaging path is determined by your contentbase! Two files are not the same

Webpack Study (iii) Webpack-dev-server cannot automatically refresh the problem

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.