Skip to content

Commit 741c4f0

Browse files
Timergaearon
authored andcommitted
Enable 1.0 docs (#2220)
* Uncomment merged PRs * Switch to br * Update some webpack links * Add a little about section for PWA * oops * fast on subsequent visits * Add manual proxy config instructions * hint package.json * Change to js for comments * Tune wording
1 parent b98ba3d commit 741c4f0

File tree

2 files changed

+81
-33
lines changed

2 files changed

+81
-33
lines changed

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ Builds the app for production to the `build` folder.<br>
100100
It correctly bundles React in production mode and optimizes the build for the best performance.
101101

102102
The build is minified and the filenames include the hashes.<br>
103-
Your app is ready to be deployed!
104-
<!--TODO: uncoment and maybe revise
105103
A [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) using an [offline-first caching strategy](https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network) is automatically generated.<br>
106-
Your ([progressive web](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)) app is ready to be deployed!-->
104+
Your ([progressive web](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)) app is ready to be deployed
107105

108106
## User Guide
109107

@@ -165,9 +163,7 @@ Please refer to the [User Guide](https://github.com/facebookincubator/create-rea
165163
* Import CSS and image files directly from JavaScript.
166164
* Autoprefixed CSS, so you don’t need `-webkit` or other prefixes.
167165
* A `build` script to bundle JS, CSS, and images for production, with sourcemaps.
168-
<!--TODO: uncomment
169166
* An offline-first [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) and a [web app manifest](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/), meeting all the [Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) criteria.
170-
-->
171167

172168
**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.
173169

packages/react-scripts/template/README.md

+80-28
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
4141
- [Node](#node)
4242
- [Ruby on Rails](#ruby-on-rails)
4343
- [Proxying API Requests in Development](#proxying-api-requests-in-development)
44+
- [Configuring the Proxy Manually](#configuring-the-proxy-manually)
4445
- [Using HTTPS in Development](#using-https-in-development)
4546
- [Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server)
4647
- [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files)
@@ -61,10 +62,8 @@ You can find the most recent version of this guide [here](https://github.com/fac
6162
- [Editor Integration](#editor-integration)
6263
- [Developing Components in Isolation](#developing-components-in-isolation)
6364
- [Making a Progressive Web App](#making-a-progressive-web-app)
64-
<!-- todo: uncomment
6565
- [Offline-First Considerations](#offline-first-considerations)
6666
- [Progressive Web App Metadata](#progressive-web-app-metadata)
67-
-->
6867
- [Deployment](#deployment)
6968
- [Static Server](#static-server)
7069
- [Other Solutions](#other-solutions)
@@ -212,7 +211,7 @@ To configure the syntax highlighting in your favorite text editor, head to the [
212211

213212
## Displaying Lint Output in the Editor
214213

215-
>Note: this feature is available with `react-scripts@0.2.0` and higher.
214+
>Note: this feature is available with `react-scripts@0.2.0` and higher.<br>
216215
>It also only works with npm 3 or higher.
217216
218217
Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint.
@@ -331,7 +330,7 @@ Learn more about ES6 modules:
331330

332331
## Adding a Stylesheet
333332

334-
This project setup uses [Webpack](https://webpack.github.io/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**:
333+
This project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**:
335334

336335
### `Button.css`
337336

@@ -446,7 +445,7 @@ Then we can change `start` and `build` scripts to include the CSS preprocessor c
446445
}
447446
```
448447

449-
Now running `npm start` and `npm run build` also builds Sass files.
448+
Now running `npm start` and `npm run build` also builds Sass files.
450449

451450
**Why `node-sass-chokidar`?**
452451

@@ -744,24 +743,23 @@ To define permanent environment variables, create a file called `.env` in the ro
744743
REACT_APP_SECRET_CODE=abcdef
745744
```
746745

747-
<!--
748-
TODO: uncomment (and tweak) the doc for 0.10
749-
What .env* files are used?
746+
`.env` files **should be** checked into source control (with the exclusion of `.env*.local`).
747+
748+
What other `.env` files are can be used?
749+
750+
>Note: this feature is available with `react-scripts@1.0.0` and higher.
750751
751752
* `.env` - Default
752753
* `.env.development`, `.env.test`, `.env.production` - Environment-specific settings.
753754
* `.env.local` - Local overrides. This file is loaded for all environments except test.
754755
* `.env.development.local`, `.env.test.local`, `.env.production.local` - Local overrides of environment-specific settings.
755756

756-
Files priority (file is skipped if does not exist):
757+
File priority, from left to right:
757758

758759
* npm test - `.env.test.local`, `env.test`, `.env.local`, `.env`
759760
* npm run build - `.env.production.local`, `env.production`, `.env.local`, `.env`
760761
* npm start - `.env.development.local`, `env.development`, `.env.local`, `.env`
761762

762-
Priority from left to right.
763-
-->
764-
765763
These variables will act as the defaults if the machine does not explicitly set them.<br>
766764
Please refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details.
767765

@@ -833,9 +831,68 @@ Keep in mind that `proxy` only has effect in development (with `npm start`), and
833831
The `proxy` option supports HTTP, HTTPS and WebSocket connections.<br>
834832
If the `proxy` option is **not** flexible enough for you, alternatively you can:
835833

834+
* [Configure the proxy yourself](#configuring-the-proxy-manually)
836835
* Enable CORS on your server ([here’s how to do it for Express](http://enable-cors.org/server_expressjs.html)).
837836
* Use [environment variables](#adding-custom-environment-variables) to inject the right server host and port into your app.
838837

838+
### Configuring the Proxy Manually
839+
840+
>Note: this feature is available with `react-scripts@1.0.0` and higher.
841+
842+
If the `proxy` option is **not** flexible enough for you, you can specify an object in the following form (in `package.json`).<br>
843+
You may also specify any configuration value [`http-proxy-middleware`](https://github.com/chimurai/http-proxy-middleware#options) or [`http-proxy`](https://github.com/nodejitsu/node-http-proxy#options) supports.
844+
```js
845+
{
846+
// ...
847+
"proxy": {
848+
"/api": {
849+
"target": "<url>",
850+
"ws": true
851+
// ...
852+
}
853+
}
854+
// ...
855+
}
856+
```
857+
858+
All requests matching this path will be proxies, no exceptions. This includes requests for `text/html`, which the standard `proxy` option does not proxy.
859+
860+
If you need to specify multiple proxies, you may do so by specifying additional entries.
861+
You may also narrow down matches using `*` and/or `**`, to match the path exactly or any subpath.
862+
```js
863+
{
864+
// ...
865+
"proxy": {
866+
// Matches any request starting with /api
867+
"/api": {
868+
"target": "<url_1>",
869+
"ws": true
870+
// ...
871+
},
872+
// Matches any request starting with /foo
873+
"/foo": {
874+
"target": "<url_2>",
875+
"ssl": true,
876+
"pathRewrite": {
877+
"^/foo": "/foo/beta"
878+
}
879+
// ...
880+
},
881+
// Matches /bar/abc.html but not /bar/sub/def.html
882+
"/bar/*.html": {
883+
"target": "<url_3>",
884+
// ...
885+
},
886+
// Matches /bar/abc.html and /bar/sub/def.html
887+
"/baz/**/*.html": {
888+
"target": "<url_4>"
889+
// ...
890+
}
891+
}
892+
// ...
893+
}
894+
```
895+
839896
## Using HTTPS in Development
840897

841898
>Note: this feature is available with `react-scripts@0.4.0` and higher.
@@ -1218,15 +1275,17 @@ Learn more about React Storybook:
12181275

12191276
## Making a Progressive Web App
12201277

1221-
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).
1222-
1223-
<!--
1224-
TODO: uncomment
12251278
By default, the production build is a fully functional, offline-first
12261279
[Progressive Web App](https://developers.google.com/web/progressive-web-apps/).
12271280

1281+
Progressive Web Apps are faster and more reliable than traditional web pages, and provide an engaging mobile experience:
1282+
1283+
* All static site assets are cached so that your page loads fast on subsequent visits, regardless of network connectivity (such as 2G or 3G). Updates are downloaded in the background.
1284+
* Your app will work regardless of network state, even if offline. This means your users will be able to use your app at 10,000 feet and on the Subway.
1285+
* On mobile devices, your app can be added directly to the user's home screen, app icon and all. You can also re-engage users using web **push notifications**. This eliminates the need for the app store.
1286+
12281287
The [`sw-precache-webpack-plugin`](https://github.com/goldhand/sw-precache-webpack-plugin)
1229-
is integrated into [`webpack.config.prod.js`](../config/webpack.config.prod.js),
1288+
is integrated into production configuration,
12301289
and it will take care of generating a service worker file that will automatically
12311290
precache all of your local assets and keep them up to date as you deploy updates.
12321291
The service worker will use a [cache-first strategy](https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network)
@@ -1265,9 +1324,8 @@ changes you've made locally.
12651324
1. If you *need* to test your offline-first service worker locally, build
12661325
the application (using `npm run build`) and run a simple http server from your
12671326
build directory. After running the build script, `create-react-app` will give
1268-
instructions for one way to test your production build locally using
1269-
`pushstate-server` and the [deployment instructions](#deployment) have
1270-
instructions for using the python `SimpleHTTPServer`. *Be sure to always use an
1327+
instructions for one way to test your production build locally and the [deployment instructions](#deployment) have
1328+
instructions for using other methods. *Be sure to always use an
12711329
incognito window to avoid complications with your browser cache.*
12721330

12731331
1. If possible,configure your production environment to serve the generated
@@ -1315,8 +1373,6 @@ icons, names, and branding colors to use when the web app is displayed.
13151373
provides more context about what each field means, and how your customizations
13161374
will affect your users' experience.
13171375

1318-
-->
1319-
13201376
## Deployment
13211377

13221378
`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.<hash>.js` are served with the contents of the `/static/js/main.<hash>.js` file.
@@ -1392,9 +1448,6 @@ It will get copied to the `build` folder when you run `npm run build`.
13921448

13931449
Now requests to `/todos/42` will be handled correctly both in development and in production.
13941450

1395-
<!--
1396-
TODO: uncomment for 1.0
1397-
13981451
On a production build, and in a browser that supports [service workers](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers),
13991452
the service worker will automatically handle all navigation requests, like for
14001453
`/todos/42`, by serving the cached copy of your `index.html`. This
@@ -1403,7 +1456,6 @@ service worker navigation routing can be configured or disabled by
14031456
[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string)
14041457
and [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp)
14051458
options of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js).
1406-
-->
14071459

14081460
### Building for Relative Paths
14091461

@@ -1675,7 +1727,7 @@ You can adjust various development and production settings by setting environmen
16751727
16761728
Variable | Development | Production | Usage
16771729
:--- | :---: | :---: | :---
1678-
BROWSER | :white_check_mark: | :x: | By default, Create React App will open the default system browser, favoring Chrome on macOS. Specify a [browser](https://github.com/sindresorhus/opn#app) to override this behavior, or set it to `none` to disable it completely. <!-- TODO: enable with 0.10: If you need to customize the way the browser is launched, you can specify a node script instead. Any arguments passed to `npm start` will also be passed to this script, and the url where your app is served will be the last argument. Your script's file name must have the `.js` extension. -->
1730+
BROWSER | :white_check_mark: | :x: | By default, Create React App will open the default system browser, favoring Chrome on macOS. Specify a [browser](https://github.com/sindresorhus/opn#app) to override this behavior, or set it to `none` to disable it completely. If you need to customize the way the browser is launched, you can specify a node script instead. Any arguments passed to `npm start` will also be passed to this script, and the url where your app is served will be the last argument. Your script's file name must have the `.js` extension.
16791731
HOST | :white_check_mark: | :x: | By default, the development web server binds to `localhost`. You may use this variable to specify a different host.
16801732
PORT | :white_check_mark: | :x: | By default, the development web server will attempt to listen on port 3000 or prompt you to attempt the next available port. You may use this variable to specify a different port.
16811733
HTTPS | :white_check_mark: | :x: | When set to `true`, Create React App will run the development server in `https` mode.
@@ -1691,7 +1743,7 @@ If this doesn’t happen, try one of the following workarounds:
16911743
16921744
* If your project is in a Dropbox folder, try moving it out.
16931745
* If the watcher doesn’t see a file called `index.js` and you’re referencing it by the folder name, you [need to restart the watcher](https://github.com/facebookincubator/create-react-app/issues/1164) due to a Webpack bug.
1694-
* Some editors like Vim and IntelliJ have a “safe write” feature that currently breaks the watcher. You will need to disable it. Follow the instructions in [“Working with editors supporting safe write”](https://webpack.github.io/docs/webpack-dev-server.html#working-with-editors-ides-supporting-safe-write).
1746+
* Some editors like Vim and IntelliJ have a “safe write” feature that currently breaks the watcher. You will need to disable it. Follow the instructions in [“Adjusting Your Text Editor”](https://webpack.js.org/guides/development/#adjusting-your-text-editor).
16951747
* If your project path contains parentheses, try moving the project to a path without them. This is caused by a [Webpack watcher bug](https://github.com/webpack/watchpack/issues/42).
16961748
* On Linux and macOS, you might need to [tweak system settings](https://webpack.github.io/docs/troubleshooting.html#not-enough-watchers) to allow more watchers.
16971749
* If the project runs inside a virtual machine such as (a Vagrant provisioned) VirtualBox, create an `.env` file in your project directory if it doesn’t exist, and add `CHOKIDAR_USEPOLLING=true` to it. This ensures that the next time you run `npm start`, the watcher uses the polling mode, as necessary inside a VM.

0 commit comments

Comments
 (0)