Skip to content

Commit

Permalink
Only create one watcher for the server (jaredpalmer#876)
Browse files Browse the repository at this point in the history
* Only create one watcher for the server

* Fix comment
  • Loading branch information
jaredpalmer authored Jan 3, 2019
1 parent 66eb779 commit 6bfeb64
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/razzle/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ function main() {
const clientCompiler = compile(clientConfig);
const serverCompiler = compile(serverConfig);

// Instatiate a variable to track server watching
let watching;

// Start our server webpack instance in watch mode after assets compile
clientCompiler.plugin('done', () => {
serverCompiler.watch(
{
quiet: true,
stats: 'none',
},
/* eslint-disable no-unused-vars */
// If we've already started the server watcher, bail early.
if (watching) {
return;
}
// Otherwise, create a new watcher for our server code.
watching = serverCompiler.watch(
{ quiet: true, stats: 'none' } /* eslint-disable no-unused-vars */,
stats => {}
);
});
Expand Down

0 comments on commit 6bfeb64

Please sign in to comment.