The output of bundle.js and webpack-dev-server

I have this output configuration in my webpack.config file:

config = { ... output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', publicPath: 'http://localhost:8090/' }, ... } 

The bundle.js package is not written to the path specified in path ; it is only available through the web server, whereas I would like to both.

What should I change in order to have both a file and a web server?

+11
source share
3 answers

When you start the webpack-dev server, you do not actually build or rebuild the web package, but only serve it from memory.

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

 webpack --watch 

running (webpack --watch will rebuild the actual package). Then in another terminal there is

 webpack-dev-server 

works, (webpack-dev-server will live and load a new assembly from memory).

+19
source

This plugin will force webpack-dev-server also write package files, eliminating the need to run two processes in the terminal.

gajus / write-file-webpack-plugin

+2
source

It looks like this is now a built-in option . You can add the following to your webpack configuration file.

 devServer: { writeToDisk: true } 

It looks like this has been added since version 3.1.10 webpack-dev-server

0
source

All Articles