Speed Up Feedback

While the production build performs the best, it’s more comfortable to use a different build environment for development. Creating the production build is slow, and the -p switch and minification lose many helpful warnings and error messages.

To improve the development experience, we’ll create a separate build script for development and replace webpack with webpack-dev-server. webpack-dev-server is a web server that builds and serves the application bundle from memory, so that the build process takes less time. We’ll set up a second npm script with different environment variables to use the React development build, and we’ll keep our existing build script unchanged.

Install webpack-dev-server with npm:

 $ ​​npm​​ ​​i​​ ​​

Get React for Real now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.