2

Here's my webpack configuration:

module.exports = {
  entry: './src/index.js',
  output: {
    path: './js',
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
      }
    ]
  },
}

I start the webpack-dev-server like this: webpack-dev-server --inline from the root directory of my app.

The problem is when I make changes in my index.js file it looks like the dev-server is bundling in the console, but I see no changes in the browser. Even after manually refreshing the served bundle.js does not change (I'm looking at it in the developer tools, I know that webpack-dev-server serves the file from memory and doesn't write changes to the file system).

Is there anything wrong in my webpack configuration or do I need to configure the webpack-dev-server somehow?

8
  • How do you refer your bundle.js? And which url do you use to view the page? localhost:8080? Commented May 25, 2016 at 10:32
  • I use localhost:8080 and my site uses bundle.js like this: <script src="js/bundle.js"></script> Commented May 25, 2016 at 10:34
  • Run server as webpack-dev-server --inline --hot Commented May 25, 2016 at 10:37
  • @BobSponge Now the output in the console is slightly different, the problem is still the same. Commented May 25, 2016 at 10:43
  • 1
    @BobSponge thats it. Thanks! Commented May 25, 2016 at 11:38

1 Answer 1

2

As Bob Sponge mentioned in the comments the problem is that the output.publicPath is missing. I've updated my config like this:

module.exports = {
  entry: './src/index.js',
  output: {
    path: './js',
    filename: 'bundle.js',
    publicPath: 'js/'
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
      }
    ]
  },
}
Sign up to request clarification or add additional context in comments.

1 Comment

Nice one! publicPath was the answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.