Facebook provides a create-react-app
command to build react apps. When we run npm run build
, we see output in /build
folder.
npm run build
Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes. Your app is ready to be deployed!
How can we use custom folder instead of /build
for the output? Thanks.
The first thing is to create a new folder and cd into that folder then run the usual npx create-react-app frontend . This is to create a react app and name the folder frontend. Cd into the frontend folder and run npm build . Once the command is done executing you will get a build folder.
Create a New React Project To create a new app/project using this tool, all we need to do is run the command "create-react-app" followed by the app name. After running the above command, a new folder called "my-sample-app" will get created and that would have all of our application code.
npm run build creates a build directory with a production build of your app. Set up your favorite HTTP server so that a visitor to your site is served index. html , and requests to static paths like /static/js/main.
Edit your package.json:
"build": "react-scripts build && mv build webapp"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With