-
Notifications
You must be signed in to change notification settings - Fork 700
Description
Problem
Our current start script runs like this:
npm run build-client-watch & npm run start-server
Webpack (build-client-watch) runs as a background job (that's what the single ampersand does). This creates a couple problems:
1: The background job can turn into a zombie process causing confusion while debugging
2: It is possible to reload a browser tab before the webpack process finishes. express will happily serve the stale bundle.js
Proposal
Use webpack-dev-middleware. Webpack ships a middleware that can be added with app.use.
Webpack dev middleware bundles the javascirpt just-in-time when it is requested. It's impossible(probably) to get a stale bundle. And there will be only one process for boilermaker projects.
Problems created
dev/deployed configuration
This will create a little more disconnect between the dev and deployed environments. It makes sense to build a bundle.js on disk for deployed environments, so we'll need to write our webpack configuration such that it can be used both by the middleware and by webpack command line. (this is not difficult)
inconsistent with other projects
We follow this pattern in some other projects, it would be best to find them and update them to follow this pattern as well. (senior enrichment, some later jr phase projects)