HotModuleReplacementPlugin doesn’t respect contentBase while serving hot-update.json

Hi.

I have a problem with contentBase and generated hot-update.json paths.

config:

...
entry: [
    'webpack/hot/dev-server',
    ...
],
contentBase: './www/',
output: { filename: 'www/index.js' },
plugins: [
    new webpack.HotModuleReplacementPlugin()
],
recordsPath: path.resolve('www/webpack.records.json')
...

www/index.html:

<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8"/>
</head>

<body>
    <div id="app"></div>
    <script src="index.js"></script>
</body>

</html>

Even with recordsPath (is it works at all?) webpack is generatin and serving *.hot-update.json files from the root, but trying to fetch them from the www (which is ok accroding to the config) so I get http://localhost:8080/www/31e32dd1f3e9bd7ea7fa.hot-update.json 404 (Not Found) errors.

Author: Fantashit

1 thought on “HotModuleReplacementPlugin doesn’t respect contentBase while serving hot-update.json

  1. just got it working with this config:

    entry: [
        'webpack/hot/dev-server',
        ...
    ],
    output: {
        filename: 'www/index.js',
        publicPath: '/'
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin()
    ]

    serving www/index.html:

    <!DOCTYPE html>
    
    <html>
    
    <head>
        <meta charset="utf-8"/>
    </head>
    
    <body>
        <div id="app"></div>
        <script src="index.js"></script>
    </body>
    
    </html>

    and opening http://localhost:8080/webpack-dev-server/www in the browser.
    but I can’t understand why it’s working 🙂 publicPath: '/'looks like a hack for me, I expecting to get hot-update.json from www/, like www/index.js, but:

                             www/index.js  861201       0  [emitted]  main
     0.6408bd7001eb5d64a19c.hot-update.js     258       0  [emitted]  main
     6408bd7001eb5d64a19c.hot-update.json
    

Comments are closed.