How to create a production build

To create a production build, we just need to run yarn build. It's that simple! See the following:

$ yarn build
yarn run v1.12.3
$ react-scripts build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

69.67 KB (+4.53 KB) build/static/js/1.877dc59d.chunk.js
21.85 KB build/static/css/1.4cb1c3c1.chunk.css
2.32 KB (+46 B) build/static/js/main.1f5d1459.chunk.js
763 B build/static/js/runtime~main.229c360f.js
507 B build/static/css/main.af121e46.chunk.css

The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:

"homepage" : "http://myname.github.io/myapp",

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:

http://bit.ly/CRA-deploy

Done in 26.70s.

You should now have a production-ready build of files in the build/ directory of your application! This is a heavily-optimized build, ready to be copied and deployed, wherever you can deploy your application!

What's important to note is that the output of this process are static files (fully compiled HTML/JS/CSS) that can be deployed and run from any place that can serve static files back to a userso, essentially, any kind of content delivery network (CDN) or web server that you may already have.

This process relies heavily on Webpack's build process and multiple different build and optimization plugins that optimize nearly every part of the build process. Files are minified, chunked by their usage and scope (to reduce importing files that we don't need), and set up in a way that allows for browser caching, to reduce as much effort as possible each time a person revisits your site!

Minified means that the files are reduced down in file size as much as possible, by renaming code, minimizing whitespace, or otherwise cutting down on extraneous code, so that the amount of JavaScript that needs to be deployed is as small as possible.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.131.238