The current version works with webpack v2, v3 and v4.
You might get a peer dependency warning when using webpack v2 or v3 but you may ignore it.
Motivation
Building applications powered by webpack with server-side rendering (isomorphic/universal apps) is hard.
When making a production build, you must compile both the client and server. When developing, we want to rebuild the client & server and bring in the new compiled code without restarting/reloading the application. This is complex, especially setting up the development server.
To make your development workflow easier to setup, webpack-isomorphic-dev-middleware offers an express middleware that:
Looks for code changes in both the client and the server and automatically compiles them
Optimizes compilation by using in-memory filesystem
Delays responses until the aggregated compiler finishes
Adds isomorphic to res.locals, which includes the webpack stats and the methods exported in your server file
Offers beautiful compilation reporting into your terminal
By default, findServerAsset selects the first JavaScript asset from first entrypoint. If that doesn't suit your Webpack configuration, you may change it:
{ // Finds the asset with the `server` word in its name findServerAssetName: (stats) => stats.assets .map((asset) => asset.name) .find((name) => /\bserver\b.+\.js$/.test(name));}
Tests
$ npm test $ npm test -- --watch during development