Renaming the ‘build’ directory generated by @wordpress/scripts for React development

I am writing this answer after testing the suggestion given by @SallyCJ (thank you for pointing me towards the right direction)

Writing the following entry into the scripts section of package.json will change both the source and destination of the React code.

"scripts": {
    "build": "wp-scripts build --webpack-src-dir=path/to/source/dir/ --output-path=path/to/destination/dir/",
    "test": "echo \"Error: no test specified\" && exit 1"
},

If you’d like to override the default entry point (i.e., use a different file than index.js as your entry point), and if this custom entry point file is located in a custom path, then here is how to setup your scripts

"scripts": {
    "build": "wp-scripts build path/to/source/dir/custom.js --webpack-src-dir=path/to/source/dir/ --output-path=path/to/destination/dir/",
    "test": "echo \"Error: no test specified\" && exit 1"
},