79624504

Date: 2025-05-16 05:02:06
Score: 1
Natty:
Report link

Script A

build": "rimraf ./build && react-scripts build && rimraf ./build/**/*.map"

What it does:

  1. rimraf ./build: Deletes the existing build/ folder (clean build).
  2. react-scripts build: Builds the app with source maps by default.
  3. rimraf ./build/**/*.map: Deletes all *.map files after the build is complete.

Result:

A clean build without source maps, but they were generated first and then deleted.

Build time is longer because source maps are created and then removed.

Script B

"build": "GENERATE_SOURCEMAP=false react-scripts build"

What it does:

Sets an environment variable to prevent react-scripts from generating source maps at all.

Skips .map file generation during build.

Result:

A clean build without source maps, but more efficient and faster.

Better for production, where you don’t want to expose your source code.

✅ Which one should you use?

Use Script B (GENERATE_SOURCEMAP=false) if you want to avoid source maps efficiently and reduce build time.

Script A is redundant and slower — only useful if you're using a toolchain that requires source maps to exist during build, but not after.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Muhammad Usama