About the solution to Webpack dev server hot loading failure, webpackdev

Source: Internet
Author: User

About the solution to Webpack dev server hot loading failure, webpackdev

When the Webpack dev server is used as the server for hot loading, the following error occurs:

XMLHttpRequest cannot load http://localhost:8080/dist/06854fc8988da94501a9.hot-update.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

Or the following warning message is displayed:

dev-server.js:37 [HMR] Update failed: Error: Manifest request to http://localhost:8080/dist/06854fc8988da94501a9.hot-update.json timed out. at XMLHttpRequest.request.onreadystatechange (http://localhost:8080/dist/main.js:38:22)

After diagnosis, the configuration error lies in the publicPath of webpack. config. js. You need to change the absolute address to the relative address, as shown below:

Output: {filename: '[name]. js', // cannot be configured as an absolute path. This is the incorrect configuration // publicPath: "http: // localhost: 8080/dist/", // This is the correct configuration, publicPath: "/dist/", path: build, // umd contains support for multiple specifications such as amd, commonjs, and var. libraryTarget: 'var '}

After repeated tests, the publicPath of webpack dev server is injected into other domains. If you use the absolute address configuration, the above error will occur.

Note that webpack dev server is the opposite of webpack-hot-middleware, and webpack-hot-middleware must use an absolute address.

The above solution to the Webpack dev server hot loading failure is all the content that I have shared with you. I hope you can give us a reference and support for more.

Related Article

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.