Skip to content

Commit b1aeeaa

Browse files
authored
Merge branch 'master' into patch-2
2 parents 29aee6d + ea1b81b commit b1aeeaa

File tree

6 files changed

+119
-94
lines changed

6 files changed

+119
-94
lines changed

README.md

+43-81
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Create React apps with no build configuration.
44

5-
* [Getting Started](#getting-started) – How to create a new app.
5+
* [Creating an App](#creating-an-app) – How to create a new app.
66
* [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
77

88
Create React App works on macOS, Windows, and Linux.<br>
@@ -11,10 +11,8 @@ If something doesn’t work, please [file an issue](https://github.com/facebooki
1111
## Quick Overview
1212

1313
```sh
14-
npm install -g create-react-app
15-
16-
create-react-app my-app
17-
cd my-app/
14+
npx create-react-app my-app
15+
cd my-app
1816
npm start
1917
```
2018

@@ -30,28 +28,17 @@ They are preconfigured and hidden so that you can focus on the code.
3028

3129
Just create a project, and you’re good to go.
3230

33-
## Getting Started
31+
## Creating an App
3432

35-
### Installation
33+
**You’ll need to have Node >= 6 on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.
3634

37-
Install it once globally:
35+
To create a new app, run a single command:
3836

3937
```sh
40-
npm install -g create-react-app
38+
npx create-react-app my-app
4139
```
4240

43-
**You’ll need to have Node >= 6 on your machine**. You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.
44-
45-
**This tool doesn’t assume a Node backend**. The Node installation is only required for Create React App itself.
46-
47-
### Creating an App
48-
49-
To create a new app, run:
50-
51-
```sh
52-
create-react-app my-app
53-
cd my-app
54-
```
41+
*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))*
5542

5643
It will create a directory called `my-app` inside the current folder.<br>
5744
Inside that directory, it will generate the initial project structure and install the transitive dependencies:
@@ -77,7 +64,13 @@ my-app
7764
```
7865

7966
No configuration or complicated folder structures, just the files you need to build your app.<br>
80-
Once the installation is done, you can run some commands inside the project folder:
67+
Once the installation is done, you can open your project folder:
68+
69+
```sh
70+
cd my-app
71+
```
72+
73+
Inside the newly created project, you can run some built-in commands:
8174

8275
### `npm start` or `yarn start`
8376

@@ -113,6 +106,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
113106
- [Updating to New Releases](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases)
114107
- [Folder Structure](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#folder-structure)
115108
- [Available Scripts](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#available-scripts)
109+
- [Supported Browsers](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#supported-browsers)
116110
- [Supported Language Features and Polyfills](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#supported-language-features-and-polyfills)
117111
- [Syntax Highlighting in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#syntax-highlighting-in-the-editor)
118112
- [Displaying Lint Output in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#displaying-lint-output-in-the-editor)
@@ -130,15 +124,19 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
130124
- [Using Global Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-global-variables)
131125
- [Adding Bootstrap](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-bootstrap)
132126
- [Adding Flow](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-flow)
127+
- [Adding a Router](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-router)
133128
- [Adding Custom Environment Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables)
134129
- [Can I Use Decorators?](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#can-i-use-decorators)
130+
- [Fetching Data with AJAX Requests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#fetching-data-with-ajax-requests)
135131
- [Integrating with an API Backend](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#integrating-with-an-api-backend)
136132
- [Proxying API Requests in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development)
137133
- [Using HTTPS in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-https-in-development)
138134
- [Generating Dynamic `<meta>` Tags on the Server](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#generating-dynamic-meta-tags-on-the-server)
139135
- [Pre-Rendering into Static HTML Files](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#pre-rendering-into-static-html-files)
140136
- [Running Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests)
137+
- [Debugging Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#debugging-tests)
141138
- [Developing Components in Isolation](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#developing-components-in-isolation)
139+
- [Publishing Components to npm](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#publishing-components-to-npm)
142140
- [Making a Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)
143141
- [Analyzing the Bundle Size](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#analyzing-the-bundle-size)
144142
- [Deployment](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment)
@@ -159,57 +157,50 @@ Please refer to the [User Guide](https://github.com/facebookincubator/create-rea
159157

160158
* **No Lock-In:** You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.
161159

162-
## Why Use This?
160+
## What’s Included?
163161

164-
**If you’re getting started** with React, use `create-react-app` to automate the build of your app. There is no configuration file, and `react-scripts` is the only extra build dependency in your `package.json`. Your environment will have everything you need to build a modern React app:
162+
Your environment will have everything you need to build a modern single-page React app:
165163

166164
* React, JSX, ES6, and Flow syntax support.
167165
* Language extras beyond ES6 like the object spread operator.
168-
* A dev server that lints for common errors.
169-
* Import CSS and image files directly from JavaScript.
170166
* Autoprefixed CSS, so you don’t need `-webkit` or other prefixes.
171-
* A `build` script to bundle JS, CSS, and images for production, with sourcemaps.
167+
* A fast interactive unit test runner with built-in support for coverage reporting.
168+
* A live development server that warns about common mistakes.
169+
* A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps.
172170
* 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.
171+
* Hassle-free updates for the above tools with a single dependency.
173172

174-
**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.
173+
Check out [this guide](https://github.com/nitishdayal/cra_closer_look) for an overview of how these tools fit together.
175174

176-
**You don’t have to use this.** Historically it has been easy to [gradually adopt](https://www.youtube.com/watch?v=BF58ZJ1ZQxY) React. However many people create new single-page React apps from scratch every day. We’ve heard [loud](https://medium.com/@ericclemmons/javascript-fatigue-48d4011b6fc4) and [clear](https://twitter.com/thomasfuchs/status/708675139253174273) that this process can be error-prone and tedious, especially if this is your first JavaScript build stack. This project is an attempt to figure out a good way to start developing React apps.
175+
The tradeoff is that **these tools are preconfigured to work in a specific way**. If your project needs more customization, you can ["eject"](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-eject) and customize it, but then you will need to maintain this configuration.
177176

178-
### Converting to a Custom Setup
177+
## Popular Alternatives
179178

180-
**If you’re a power user** and you aren’t happy with the default configuration, you can “eject” from the tool and use it as a boilerplate generator.
179+
Create React App is a great fit for:
181180

182-
Running `npm run eject` copies all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. Commands like `npm start` and `npm run build` will still work, but they will point to the copied scripts so you can tweak them. At this point, you’re on your own.
181+
* **Learning React** in a comfortable and feature-rich development environment.
182+
* **Starting new single-page React applications.**
183+
* **Creating examples** with React for your libraries and components.
183184

184-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
185+
Here’s a few common cases where you might want to try something else:
185186

186-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
187+
* If you want to **try React** without hundreds of transitive build tool dependencies, consider [using a single HTML file or an online sandbox instead](https://reactjs.org/docs/try-react.html).
187188

188-
## Limitations
189+
* If you need to **integrate React code with a server-side template framework** like Rails or Django, or if you’re **not building a single-page app**, consider using [nwb](https://github.com/insin/nwb) or [Neutrino](https://neutrino.js.org/) which are more flexible.
189190

190-
Some features are currently **not supported**:
191+
* If you need to **publish a React component**, [nwb](https://github.com/insin/nwb) can [also do this](https://github.com/insin/nwb#react-components-and-libraries).
191192

192-
* Server rendering.
193-
* Some experimental syntax extensions (e.g. decorators).
194-
* CSS Modules (see [#2285](https://github.com/facebookincubator/create-react-app/pull/2285)).
195-
* Importing LESS or Sass directly ([but you still can use them](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-preprocessor-sass-less-etc)).
196-
* Hot reloading of components.
193+
* If you want to do **server rendering** with React and Node.js, check out [Next.js](https://github.com/zeit/next.js/) or [Razzle](https://github.com/jaredpalmer/razzle). Create React App is agnostic of the backend, and just produces static HTML/JS/CSS bundles.
197194

198-
Some of them might get added in the future if they are stable, are useful to majority of React apps, don’t conflict with existing tools, and don’t introduce additional configuration.
195+
* If your website is **mostly static** (for example, a portfolio or a blog), consider using [Gatsby](https://www.gatsbyjs.org/) instead. Unlike Create React App, it pre-renders the website into HTML at the build time.
199196

200-
## What’s Inside?
197+
* If you want to use **TypeScript**, consider using [create-react-app-typescript](https://github.com/wmonk/create-react-app-typescript).
201198

202-
The tools used by Create React App are subject to change.
203-
Currently it is a thin layer on top of many amazing community projects, such as:
199+
* Finally, if you need **more customization**, check out [Neutrino](https://neutrino.js.org/) and its [React preset](https://neutrino.js.org/packages/react/).
204200

205-
* [webpack](https://webpack.js.org/) with [webpack-dev-server](https://github.com/webpack/webpack-dev-server), [html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin) and [style-loader](https://github.com/webpack/style-loader)
206-
* [Babel](http://babeljs.io/) with ES6 and extensions used by Facebook (JSX, [object spread](https://github.com/sebmarkbage/ecmascript-rest-spread/commits/master), [class properties](https://github.com/jeffmo/es-class-public-fields))
207-
* [Autoprefixer](https://github.com/postcss/autoprefixer)
208-
* [ESLint](http://eslint.org/)
209-
* [Jest](http://facebook.github.io/jest)
210-
* and others.
201+
All of the above tools can work with little to no configuration.
211202

212-
All of them are transitive dependencies of the provided npm package.
203+
If you prefer configuring the build yourself, [follow this guide](https://reactjs.org/docs/add-react-to-an-existing-app.html).
213204

214205
## Contributing
215206

@@ -227,32 +218,3 @@ We are grateful to the authors of existing related projects for their ideas and
227218
* [@eanplatter](https://github.com/eanplatter)
228219
* [@insin](https://github.com/insin)
229220
* [@mxstbr](https://github.com/mxstbr)
230-
231-
## Alternatives
232-
233-
If you don’t agree with the choices made in this project, you might want to explore alternatives with different tradeoffs.<br>
234-
Some of the more popular and actively maintained ones are:
235-
236-
* [insin/nwb](https://github.com/insin/nwb)
237-
* [mozilla-neutrino/neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev)
238-
* [jaredpalmer/razzle](https://github.com/jaredpalmer/razzle)
239-
* [NYTimes/kyt](https://github.com/NYTimes/kyt)
240-
* [zeit/next.js](https://github.com/zeit/next.js)
241-
* [gatsbyjs/gatsby](https://github.com/gatsbyjs/gatsby)
242-
* [electrode-io/electrode](https://github.com/electrode-io/electrode)
243-
244-
Notable alternatives also include:
245-
246-
* [enclave](https://github.com/eanplatter/enclave)
247-
* [motion](https://github.com/steelbrain/pundle/tree/master/packages/motion)
248-
* [quik](https://github.com/satya164/quik)
249-
* [sagui](https://github.com/saguijs/sagui)
250-
* [roc](https://github.com/rocjs/roc)
251-
* [aik](https://github.com/d4rkr00t/aik)
252-
* [react-app](https://github.com/kriasoft/react-app)
253-
* [dev-toolkit](https://github.com/stoikerty/dev-toolkit)
254-
* [sku](https://github.com/seek-oss/sku)
255-
* [gluestick](https://github.com/TrueCar/gluestick)
256-
257-
You can also use module bundlers like [webpack](http://webpack.js.org) and [Browserify](http://browserify.org/) directly.<br>
258-
React documentation includes [a walkthrough](https://reactjs.org/docs/installation.html#development-and-production-versions) on this topic.

packages/eslint-config-react-app/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module.exports = {
116116
'new-parens': 'warn',
117117
'no-array-constructor': 'warn',
118118
'no-caller': 'warn',
119-
'no-cond-assign': ['warn', 'always'],
119+
'no-cond-assign': ['warn', 'except-parens'],
120120
'no-const-assign': 'warn',
121121
'no-control-regex': 'warn',
122122
'no-delete-var': 'warn',

packages/react-dev-utils/clearConsole.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
'use strict';
99

1010
function clearConsole() {
11-
process.stdout.write(
12-
process.platform === 'win32' ? '\x1Bc' : '\x1B[2J\x1B[3J\x1B[H'
13-
);
11+
process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H');
1412
}
1513

1614
module.exports = clearConsole;

packages/react-dev-utils/ignoredFiles.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
'use strict';
99

1010
const path = require('path');
11+
const escape = require('escape-string-regexp');
1112

1213
module.exports = function ignoredFiles(appSrc) {
1314
return new RegExp(
14-
`^(?!${path
15-
.normalize(appSrc + '/')
16-
.replace(/[\\]+/g, '/')}).+/node_modules/`,
15+
`^(?!${escape(
16+
path.normalize(appSrc + '/').replace(/[\\]+/g, '/')
17+
)}).+/node_modules/`,
1718
'g'
1819
);
1920
};

packages/react-dev-utils/launchEditor.js

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ const COMMON_EDITORS_OSX = {
5252
'/Applications/RubyMine.app/Contents/MacOS/rubymine',
5353
'/Applications/WebStorm.app/Contents/MacOS/webstorm':
5454
'/Applications/WebStorm.app/Contents/MacOS/webstorm',
55+
'/Applications/MacVim.app/Contents/MacOS/MacVim':
56+
'mvim',
5557
};
5658

5759
const COMMON_EDITORS_LINUX = {
@@ -257,11 +259,16 @@ function launchEditor(fileName, lineNumber) {
257259
}
258260

259261
let [editor, ...args] = guessEditor();
262+
260263
if (!editor) {
261264
printInstructions(fileName, null);
262265
return;
263266
}
264267

268+
if (editor.toLowerCase() === 'none') {
269+
return;
270+
}
271+
265272
if (
266273
process.platform === 'linux' &&
267274
fileName.startsWith('/mnt/') &&

0 commit comments

Comments
 (0)