Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack dev server hot mode not working

Heres my config:

devServer: {
    contentBase: '/web/dist/',
    hot: true,
    stats: {colors: true},
    inline: true
}

And here's the gulp task im running:

gulp.task('build', ['clean', 'styles', 'bower', 'media', 'data', 'homepage'], function(done) {
    es6promise.polyfill();

    console.log('STARTING DEV SERVER...');

    server = new WebpackDevServer(webpack(webpackDevConfig), webpackDevConfig.devServer);
    server.listen(8080, '0.0.0.0', function (err, stats) {
        if (err) {
             throw new gutil.PluginError("webpack-dev-server", err);
        }

        console.log('DEV SERVER STARTED');

        done();
    });
});

Everything works as expected except the hot loading (no refresh or change when I make changes to files). What am I doing wrong here?

like image 820
Evan Avatar asked May 28 '15 16:05

Evan


2 Answers

You need to add <script src="http://localhost:8080/webpack-dev-server.js"></script> to your index.html It is not added when you use the API

"Notice that webpack configuration is not passed to WebpackDevServer API, thus devServer option in webpack configuration is not used in this case. Also, there is no inline mode for WebpackDevServer API. <script src="http://localhost:8080/webpack-dev-server.js"></script> should be inserted to HTML page manually." (http://webpack.github.io/docs/webpack-dev-server.html)

maybe you also need to add 'webpack/hot/dev-server' as an entrypoint to your webpack config

like image 63
errnesto Avatar answered Oct 31 '22 22:10

errnesto


be sure to set

webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());

in the webpackConfig as well

like image 24
Elise Chant Avatar answered Oct 31 '22 22:10

Elise Chant