looking for some solutions? You are welcome.

SOLVED: Why Webpack devServer chunks is requested from wrong path?


I'am trying to use dynamic import with React.lazy. Code is quite simple

import React, { Component, Suspense, lazy, } from 'react';

const BlazyComponent = lazy(() => {

    return import('./blazy');

class Main extends Component {

    render () {

        return (<Suspense fallback={<div>Loading...</div>}>

export default Main;

So, when I'am starting Webpack devServer, browser console show an error

index.js:114 Uncaught (in promise) Error: Loading chunk 0 failed.
(missing: http://domain/build/0.js)
    at HTMLScriptElement.onScriptComplete (index.js:114)

As I can see, index.css and index.js bundles are successfully loaded from http://domain:8080/build/test/index.css and http://domain:8080/build/test/index.js.

But chunk loads from http://domain/build/0.js (webpack devServer ignores port). How can I force chunk load from http://domain:8080/build/0.js.

Webpack config

entry: {

    'test/index': [ 'babel-polyfill', './resources/assets/modules/test/index', ],
output: {

    path: path.resolve(__dirname, './public/build/'),
    publicPath: '/build/',
    filename: '[name].js',
    chunkFilename: '[name].js',
devServer: {

    host: 'domain',
    port: 8080,

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: