What is webpack dev server?
Webpack dev server is a live reloading server for webpack.
What is webpack dev middleware?
It’s a simple wrapper middleware for webpack. It serves the files emitted from webpack over a connect server.
It has a few advantages over bundling it as files:
- No files are written to disk, it handles the files in memory
- If files changed in watch mode, the middleware no longer serves the old bundle, but delays requests until the compiling has finished. You don’t have to wait before refreshing the page after a file modification.
What is webpack hot middleware?
Webpack hot reloading using only webpack-dev-middleware. This allows you to add hot reloading into an existing server without webpack-dev-server.
Using webpack-dev-server as a middleware
Web pack provides an express middleware that you can plug into your app to serve up your fronted assets via web pack-dev-server rather than express.static or express/serve-static.
To do this you’ll need to install webpack-dev-middleware and webpack-hot-middleware
First off you need to make a webpack.dev.config file.
In your config, add
webpack-hot-middleware/client to your entry point as well as your js or coffee script frontend entry point.
1 2 3 4 5
Make your output path ‘/‘ because remember, you’re building your app into memory now rather than a build folder.
1 2 3 4 5
Add in whatever loaders and plugins you need and target ‘web’ … you can see my config hereRead on →