Chris Noring
Chris Noring

Reputation: 471

Webpack --hot in windows not rebuilding bundle

So I am using webpack-dev-server and its live reload ability. I am on a windows machine. When I change a js file it seems to be reloading the browser but it doesn't rebuild the bundle. Here is my webpack config file

var webpack = require("webpack");
var path = require('path');

module.exports = {
  entry: ['./app/thirdparty', "./app/app.js"],
  output: {
    filename: "./build/bundle.js",
    publicPath: "/assets/"
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ],
  module: {
    loaders: [{
      test: /\.js$/,
      exclude: /node_modules/,
      loader: "babel-loader"
    }]
  },
  resolve: {
    extensions: ['', '.js', '.es6']
  },
  include: path.join(__dirname, 'app')
}

I've tried to run it with

webpack-dev-server

and

webpack-dev-server --hot

But the bundle is not rebuilt

Upvotes: 1

Views: 913

Answers (1)

Chris Noring
Chris Noring

Reputation: 471

So I solved my own question. I had a file looking like :

output: {
   filename: "./build/bundle.js",
   publicPath: "/assets/"
}

I changed it to

output : {
    path: path.resolve('build/js'),
    publicPath: "/public/js/",
    filename : "bundle.js",

}

Which means it will create a bundle.js that will end up in /build/js/bundle.js BUT it needs to be referred to in index.html as public/js/bundle.js because of how the publicPath is specified. Also running

webpack-dev-server --inline

Made everything work. Its obvious once you understand web pack I guess...

Upvotes: 1

Related Questions