diff --git a/README.md b/README.md
index 4a0eeab567a..e9658d8585c 100644
--- a/README.md
+++ b/README.md
@@ -101,6 +101,9 @@ It correctly bundles React in production mode and optimizes the build for the be
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
+
## User Guide
@@ -162,6 +165,9 @@ Please refer to the [User Guide](https://github.com/facebookincubator/create-rea
* Import CSS and image files directly from JavaScript.
* Autoprefixed CSS, so you don’t need `-webkit` or other prefixes.
* A `build` script to bundle JS, CSS, and images for production, with sourcemaps.
+
**The feature set is intentionally limited**. It doesn’t support advanced features such as server rendering or CSS modules. The tool is also **non-configurable** because it is hard to provide a cohesive experience and easy updates across a set of tools when the user can tweak anything.
diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js
index 182105c756a..b2ad37325b0 100644
--- a/packages/react-scripts/config/webpack.config.prod.js
+++ b/packages/react-scripts/config/webpack.config.prod.js
@@ -17,6 +17,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
+const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
const paths = require('./paths');
const getClientEnvironment = require('./env');
@@ -286,6 +287,19 @@ module.exports = {
new ManifestPlugin({
fileName: 'asset-manifest.json',
}),
+ // Generate a service worker script that will precache, and keep up to date,
+ // the HTML & assets that are part of the Webpack build.
+ new SWPrecacheWebpackPlugin({
+ // By default, a cache-busting query parameter is appended to requests
+ // used to populate the caches, to ensure the responses are fresh.
+ // If a URL is already hashed by Webpack, then there is no concern
+ // about it being stale, and the cache-busting can be skipped.
+ dontCacheBustUrlsMatching: /\.\w{8}\./,
+ filename: 'service-worker.js',
+ minify: true,
+ navigateFallback: publicUrl + '/index.html',
+ staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
+ }),
// Moment.js is an extremely popular library that bundles large locale files
// by default due to how Webpack interprets its code. This is a practical
// solution that requires the user to opt into importing specific locales.
diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json
index eaab334d4c3..939e40d809f 100644
--- a/packages/react-scripts/package.json
+++ b/packages/react-scripts/package.json
@@ -56,6 +56,7 @@
"react-dev-utils": "^1.0.0",
"react-error-overlay": "^1.0.0",
"style-loader": "0.17.0",
+ "sw-precache-webpack-plugin": "0.9.1",
"url-loader": "0.5.8",
"webpack": "2.5.1",
"webpack-dev-server": "2.4.5",
diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md
index b25f723c97b..50bbf7b694a 100644
--- a/packages/react-scripts/template/README.md
+++ b/packages/react-scripts/template/README.md
@@ -61,6 +61,10 @@ You can find the most recent version of this guide [here](https://github.com/fac
- [Editor Integration](#editor-integration)
- [Developing Components in Isolation](#developing-components-in-isolation)
- [Making a Progressive Web App](#making-a-progressive-web-app)
+
- [Deployment](#deployment)
- [Static Server](#static-server)
- [Other Solutions](#other-solutions)
@@ -1216,6 +1220,103 @@ Learn more about React Storybook:
You can turn your React app into a [Progressive Web App](https://developers.google.com/web/progressive-web-apps/) by following the steps in [this repository](https://github.com/jeffposnick/create-react-pwa).
+
+
## Deployment
`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.
@@ -1291,6 +1392,19 @@ It will get copied to the `build` folder when you run `npm run build`.
Now requests to `/todos/42` will be handled correctly both in development and in production.
+
+
### Building for Relative Paths
By default, Create React App produces a build assuming your app is hosted at the server root.
diff --git a/packages/react-scripts/template/public/index.html b/packages/react-scripts/template/public/index.html
index 7f3e83f4e43..fc8689a2a29 100644
--- a/packages/react-scripts/template/public/index.html
+++ b/packages/react-scripts/template/public/index.html
@@ -3,9 +3,15 @@
+
+
+