From 126ed4e66979ce4bc95499f9a253343c0858c069 Mon Sep 17 00:00:00 2001 From: Pierre Avital Date: Fri, 4 Mar 2022 16:25:33 +0100 Subject: [PATCH] Faster builds with `react-scripts build --dev` Hello, I'll be honest, I've been going straight for the simplest solution, and I haven't actually tested it. Definitely review this before merging. I'm mostly doing this PR to try and prompt the maintainers to let such a thing exist. I feel like there's too big a leap from `start` to `build`, as one also spawns a server (not required for my usecase), whereas the other only does production-optimized builds. This might not be the cleanest way to do it, but I think this would allow a middle ground where one can run fast builds without spawning a server (useful when an other server is already serving the build folder). --- packages/react-scripts/scripts/build.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 7a3a635a5d3..f198b92ca95 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -53,9 +53,10 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { const argv = process.argv.slice(2); const writeStatsJson = argv.indexOf('--stats') !== -1; +const productionMode = argv.indexOf('--dev') === -1; // Generate configuration -const config = configFactory('production'); +const config = configFactory(productionMode ? 'production' : 'development'); // We require that you explicitly set browsers and do not fall back to // browserslist defaults.