From 14a98dc9e6cba40c0fb2aacea2e839f3b84b5b23 Mon Sep 17 00:00:00 2001 From: dbertella Date: Thu, 21 Dec 2017 10:08:46 +0000 Subject: [PATCH] Update documentation, add file compression --- packages/react-scripts/template/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index cbb57d8cdc2..66b987dc595 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -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) @@ -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..js` are served with the contents of the `/static/js/main..js` file.