bundle.js file output and webpack-dev-server

When you run webpack-dev-server you are not actually bundling and rebuilding the webpack bundle, it is only serving it from memory.

In my experience, the way around this is to have two instances running if you wand to have the actual build as well as the webpack-dev-server. So, in one terminal window have

webpack --watch

running, ( webpack --watch will rebuild the actual bundle ). Then, in another terminal have

webpack-dev-server

running, ( webpack-dev-server will live reaload and serve from memory the new build ).


[Original]

It appears this is now a built-in option. You can add the following in your webpack config file.

devServer: {
  writeToDisk: true
}

Looks like this was added as of webpack-dev-server version 3.1.10


[2021-11-09] Webpack 5 The syntax appears to have changed in Webpack 5 (you now pass a config option to the specific middleware that handles the assets):

module.exports = {
  devServer: {
    devMiddleware: {
      writeToDisk: true,
    },
  },
};

Webpack v4 docs: https://v4.webpack.js.org/configuration/dev-server/#devserverwritetodisk- Webpack v5 docs: https://webpack.js.org/configuration/dev-server/#devserverdevmiddleware