Skip to content

Update documentation, add file compression #3632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/react-scripts/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
- [Offline-First Considerations](#offline-first-considerations)
- [Progressive Web App Metadata](#progressive-web-app-metadata)
- [Analyzing the Bundle Size](#analyzing-the-bundle-size)
- [File Compression](#file-compression)
- [Deployment](#deployment)
- [Static Server](#static-server)
- [Other Solutions](#other-solutions)
Expand Down Expand Up @@ -1811,6 +1812,19 @@ npm run build
npm run analyze
```

## File Compression

Build script shows files size after gzip compression but the real output in the build folder is only minified. A simple way to achieve the compression is to add a postbuild script in the package.json
```diff
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
+ "postbuild": "gzip -r build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
```

## Deployment

`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.<hash>.js` are served with the contents of the `/static/js/main.<hash>.js` file.
Expand Down