ctrlplusb / react-universally

A starter kit for universal react applications.
MIT License
1.7k stars 244 forks source link

Question: Disabling bundling on file save #587

Closed mb8z closed 6 years ago

mb8z commented 6 years ago

First of all - great boilerplate. I've learned so many things from analyzing it! And it works great with a real production apps.

I'm facing one issue with my laptop - I have a pretty big project and each bundling takes 8-10s. I sometimes found myself editing multiple files really fast and those bundles are being generated like crazy 😂

My question is - is it easily possible to disable this hot reload on each file save and perform it for example on pressing enter in my terminal?

mb8z commented 6 years ago

Well, I think I found some kind of a workaround. For anyone that will also face a similar issue - you can add a watchOptions attribute in ./internal/development/hotClientServer.js inside the createWebpackMiddleware.

Mine currently looks like this:

this.webpackDevMiddleware = createWebpackMiddleware(compiler, {
      quiet: true,
      noInfo: true,
      headers: {
        'Access-Control-Allow-Origin': `http://${config('host')}:${config('port')}`,
      },
      // Ensure that the public path is taken from the compiler webpack config
      // as it will have been created as an absolute path to avoid conflicts
      // with an node servers.
      publicPath: compiler.options.output.publicPath,
      watchOptions: {
        aggregateTimeout: 2000, // Wait 2000ms from the first file change to bundle
        poll: 2000, // Check for changes every 2000ms
      },
    });
ctrlplusb commented 6 years ago

That is a great tip 👍