13

This is in my webpack.config.js:

var path = require('path');
module.exports = {
  entry: './src/index.jsx',
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'bundle.js'
  },
  devServer: {
    inline: true,
    port: 8080
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react']
        }
      }
    ]
  }
}

And this is how I run it:

$ webpack-dev-server --watch-poll --progress --colors
$ webpack --progress --colors

The problem I'm having is that webpack-dev-server is serving the bundle file at the root of my folder (not on the build) folder how I would expect. But webpack outputs the bundle file to build/ (how I expect) to.

So I have to change the script scr when I do a build.

Is there a way to solve that? Maybe is just bad configuration on my webpack.config.js.

I'm running ubuntu BTW.

1 Answer 1

15

publicPath tells webpack-dev-server where to serve your bundle in memory

output: {
   path: path.resolve(__dirname, 'build'),
   filename: 'bundle.js',
   publicPath: '/build/'
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Totally missed that.

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.