Let's take a look at what happens when we prepare our React project for deployment. Run npm run build and observe the output. You should see an output similar to the following:
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
39.39 KB build/static/js/2.deae54a5.chunk.js
776 B build/static/js/runtime-main.70500df8.js
650 B build/static/js/main.0fefaef6.chunk.js
547 B build/static/css/main.5f361e03.chunk.css
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
You may serve it with a static server:
yarn global add serve
serve -s build
Find out more about deployment here:
bit.ly/CRA-deploy
If you take a look inside your build directory, you'll see nicely minified JavaScript files, packaged for efficient deployment. Here's the fun part: npm run build from create-react-app uses webpack under the hood! The...