6

Currently I made a simple app with react, it works perfectly and I use react-scripts. I installed React by following the Facebook github page, and it written that "When you're ready to deploy to production, running npm run build will create an optimized build of your app in the build folder. ". After I press npm run build, a folder build created, but I do not know what to do with this folder. I tried some method like, move all folders except build and npm run, but it did not work. Anyone can explain me what is this folder "build" ? Thank you

2
  • You can figure this out by looking at package.json file Commented Jul 26, 2017 at 8:05
  • yeah, but it calls react-scripts which I dont know what this script doing, Thanks btw Commented Jul 26, 2017 at 8:10

1 Answer 1

4

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.

npm run build creates a build directory with a production build of your app. Set up your favourite HTTP server so that a visitor to your site is served index.html, and requests to static paths like /static/js/main..js are served with the contents of the /static/js/main..js file.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks Voi, but could you explain to me how can I open my app only using the build directory ? I expect build directory is like "minified" version of my app. Thank you
after npm run build you can open your app with your cmd with npm start :D. Easier you can read this page github.com/facebookincubator/create-react-app#create-react-app-. ^^ . All is already explained ^^
Hi, but after I type npm start, it did not give any difference. it is written "Note that the development build is not optimized. To create a production build, use npm run build."
have you used "npm run build"
I did, this is the message after I run build: Creating an optimized production build... Compiled successfully. File sizes after gzip: 49.4 KB build/static/js/main.2df24179.js 173 B build/static/css/main.4f0bb42e.css The project was built assuming it is hosted at the server root. To override this, specify the homepage in your package.json. For example, add this to build it for GitHub Pages: "homepage" : "myname.github.io/myapp", The build folder is ready to be deployed. You may serve it with a static server: npm install -g serve serve -s build

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.