Skip to content

Commit c1deb6a

Browse files
committed
Merge branch 'master' into port-option-for-npm-start
2 parents 63b4290 + 458d3f9 commit c1deb6a

File tree

9 files changed

+136
-29
lines changed

9 files changed

+136
-29
lines changed

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Contributing to `create-react-app`
2+
3+
`create-react-app` and want to get involved? Thanks! There are plenty of ways you can help!
4+
5+
Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
6+
7+
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
8+
9+
## Core ideas
10+
11+
We do not want any flags or configuration, that would defeat the purpose of this tool. We want to find good defaults and actively find ways to improve the developer experience.
12+
13+
We try not to make any controversial choices. If the community is split between different tools, we won't just pick the least controversial or most popular, the tool itself should be agnostic between them.
14+
15+
*These ideas are subject to change at any time*
16+
17+
## Submitting a Pull Request
18+
19+
Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.
20+
21+
Please **ask first** if somebody else is already working on this or the core developers think your feature is in-scope for `create-react-app`. Generally always have a related issue with discussions for whatever you are including.
22+
23+
Please also provide a **test plan**, i.e. specify how you verified what you added works.
24+
25+
## Setting up a local copy of the repository
26+
27+
1. Clone the repo with `git clone https://github.com/facebookincubator/create-react-app`
28+
29+
2. Run `npm install` in the root `create-react-app` folder **and** the `create-react-app/global-cli` folder
30+
31+
Once it is done, you can modify any file locally and run `npm start` or `npm run build` just like in a generated project.
32+
33+
If you want to try out the end-to-end flow with the global CLI, you can do this too:
34+
35+
```
36+
npm run create-react-app my-app
37+
cd my-app
38+
```
39+
40+
and then run `npm start` or `npm run build`.
41+
42+
*Many thanks to [h5bp](https://github.com/h5bp/html5-boilerplate/blob/master/CONTRIBUTING.md) for the inspiration with this contributing guide*

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,7 @@ All of them are transient dependencies of the provided npm package.
146146

147147
## Contributing
148148

149-
Clone the repo and run `npm install` in the root and the `global-cli` folder.
150-
151-
Once it is done, you can modify any file locally and run `npm start` or `npm run build` just like in a generated project.
152-
If you want to try out the end-to-end flow with the global CLI, you can do this too:
153-
154-
```
155-
npm run create-react-app my-app
156-
cd my-app
157-
```
158-
159-
and then run `npm start` or `npm run build`.
149+
We'd love to have your helping hand on `create-react-app`! See [CONTRIBUTING.md](CONTRIBUTING.md) for more information on what we're looking for and how to get started.
160150

161151
## Acknowledgements
162152

config/eslint.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,6 @@ module.exports = {
179179

180180
// https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
181181
'react/jsx-equals-spacing': [WARNING, 'never'],
182-
'react/jsx-handler-names': [WARNING, {
183-
eventHandlerPrefix: 'handle',
184-
eventHandlerPropPrefix: 'on',
185-
}],
186182
'react/jsx-no-duplicate-props': [WARNING, { ignoreCase: true }],
187183
'react/jsx-no-undef': WARNING,
188184
'react/jsx-pascal-case': [WARNING, {

config/webpack.config.prod.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var autoprefixer = require('autoprefixer');
1212
var webpack = require('webpack');
1313
var HtmlWebpackPlugin = require('html-webpack-plugin');
1414
var ExtractTextPlugin = require('extract-text-webpack-plugin');
15+
var url = require('url');
1516

1617
// TODO: hide this behind a flag and eliminate dead code on eject.
1718
// This shouldn't be exposed to the user.
@@ -26,6 +27,12 @@ var nodeModulesPath = path.join(__dirname, '..', 'node_modules');
2627
var indexHtmlPath = path.resolve(__dirname, relativePath, 'index.html');
2728
var faviconPath = path.resolve(__dirname, relativePath, 'favicon.ico');
2829
var buildPath = path.join(__dirname, isInNodeModules ? '../../..' : '..', 'build');
30+
var homepagePath = require(path.resolve(__dirname, relativePath, 'package.json')).homepage;
31+
var publicPath = homepagePath ? url.parse(homepagePath).pathname : '/';
32+
if (!publicPath.endsWith('/')) {
33+
// Prevents incorrect paths in file-loader
34+
publicPath += '/';
35+
}
2936

3037
module.exports = {
3138
bail: true,
@@ -35,9 +42,7 @@ module.exports = {
3542
path: buildPath,
3643
filename: '[name].[chunkhash].js',
3744
chunkFilename: '[name].[chunkhash].chunk.js',
38-
// TODO: this wouldn't work for e.g. GH Pages.
39-
// Good news: we can infer it from package.json :-)
40-
publicPath: '/'
45+
publicPath: publicPath
4146
},
4247
resolve: {
4348
extensions: ['', '.js'],

scripts/build.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ var config = require('../config/webpack.config.prod');
1616

1717
var isInNodeModules = 'node_modules' ===
1818
path.basename(path.resolve(path.join(__dirname, '..', '..')));
19-
var relative = isInNodeModules ? '../..' : '.';
20-
rimrafSync(relative + '/build');
19+
var relative = isInNodeModules ? '../../..' : '..';
20+
if (process.argv[2] === '--debug-template') {
21+
relative = '../template';
22+
}
23+
var packageJsonPath = path.join(__dirname, relative, 'package.json');
24+
var buildPath = path.join(__dirname, relative, 'build');
25+
rimrafSync(buildPath);
2126

2227
webpack(config).run(function(err, stats) {
2328
if (err) {
@@ -27,13 +32,28 @@ webpack(config).run(function(err, stats) {
2732
}
2833

2934
var openCommand = process.platform === 'win32' ? 'start' : 'open';
35+
var homepagePath = require(packageJsonPath).homepage;
3036
console.log('Successfully generated a bundle in the build folder!');
31-
console.log();
32-
console.log('You can now serve it with any static server, for example:');
33-
console.log(' cd build');
34-
console.log(' npm install -g http-server');
35-
console.log(' hs');
36-
console.log(' ' + openCommand + ' http://localhost:8080');
37-
console.log();
37+
if (homepagePath) {
38+
console.log('You can now deploy it to ' + homepagePath + '.');
39+
console.log('For example, if you use GitHub Pages:');
40+
console.log();
41+
console.log(' git checkout -B gh-pages');
42+
console.log(' git add -f build');
43+
console.log(' git commit -am "Rebuild website"');
44+
console.log(' git push origin :gh-pages');
45+
console.log(' git subtree push --prefix build origin gh-pages');
46+
console.log(' git checkout -');
47+
console.log();
48+
} else {
49+
console.log('You can now serve it with any static server.');
50+
console.log('For example:');
51+
console.log();
52+
console.log(' cd build');
53+
console.log(' npm install -g http-server');
54+
console.log(' hs');
55+
console.log(' ' + openCommand + ' http://localhost:8080');
56+
console.log();
57+
}
3858
console.log('The bundle is optimized and ready to be deployed to production.');
3959
});

scripts/eject.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
104104
});
105105
delete hostPackage.scripts['eject'];
106106

107+
// explicitly specify ESLint config path for editor plugins
108+
hostPackage.eslintConfig = {
109+
extends: './config/eslint.js',
110+
};
111+
107112
console.log('Writing package.json');
108113
fs.writeFileSync(
109114
path.join(hostPath, 'package.json'),

scripts/init.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ module.exports = function(hostPath, appName, verbose) {
2929
hostPackage.scripts[command] = 'react-scripts ' + command;
3030
});
3131

32+
// explicitly specify ESLint config path for editor plugins
33+
hostPackage.eslintConfig = {
34+
extends: './node_modules/react-scripts/config/eslint.js',
35+
};
36+
3237
fs.writeFileSync(
3338
path.join(hostPath, 'package.json'),
3439
JSON.stringify(hostPackage, null, 2)
@@ -64,13 +69,14 @@ module.exports = function(hostPath, appName, verbose) {
6469
}
6570

6671
console.log('Success! Created ' + appName + ' at ' + hostPath + '.');
67-
console.log();
6872
console.log('Inside that directory, you can run several commands:');
73+
console.log();
6974
console.log(' * npm start: Starts the development server.');
7075
console.log(' * npm run build: Bundles the app into static files for production.');
7176
console.log(' * npm run eject: Removes this tool. If you do this, you can’t go back!');
7277
console.log();
7378
console.log('We suggest that you begin by typing:');
79+
console.log();
7480
console.log(' cd', cdpath);
7581
console.log(' npm start');
7682
console.log();

template/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Please be advised that this is also a custom feature of Webpack.
219219

220220
**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images). However it may not be portable to some other environments, such as Node.js and Browserify. If you prefer to reference static assets in a more traditional way outside the module system, please let us know [in this issue](https://github.com/facebookincubator/create-react-app/issues/28), and we will consider support for this.
221221

222-
### Adding Flow
222+
### Add Flow
223223

224224
Flow typing is currently [not supported out of the box](https://github.com/facebookincubator/create-react-app/issues/72) with the default `.flowconfig` generated by Flow. If you run it, you might get errors like this:
225225

@@ -275,6 +275,32 @@ module.name_mapper='^\(.*\)\.\(jpg\|png\|gif\|eot\|svg\|ttf\|woff\|woff2\|mp4\|w
275275

276276
We will consider integrating more tightly with Flow in the future so that you don’t have to do this.
277277

278+
### Deploy to GitHub Pages
279+
280+
First, open your `package.json` and add a `homepage` field.
281+
It could look like this:
282+
283+
```js
284+
{
285+
"name": "my-app",
286+
"homepage": "http://myusername.github.io/my-app",
287+
// ...
288+
}
289+
```
290+
291+
Now, whenever you run `npm run build`, you will see a cheat sheet with a sequence of commands to deploy to GitHub pages:
292+
293+
```sh
294+
git checkout -B gh-pages
295+
git add -f build
296+
git commit -am "Rebuild website"
297+
git push origin :gh-pages
298+
git subtree push --prefix build origin gh-pages
299+
git checkout -
300+
```
301+
302+
You may copy and paste them, or put them into a custom shell script. You may also customize them for another hosting provider.
303+
278304
### Something Missing?
279305

280306
If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/template/README.md)

template/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "my-app",
3+
"version": "0.0.1",
4+
"private": true,
5+
"devDependencies": {
6+
"react-scripts": "0.1.0"
7+
},
8+
"dependencies": {
9+
"react": "^15.2.1",
10+
"react-dom": "^15.2.1"
11+
},
12+
"scripts": {
13+
"start": "react-scripts start",
14+
"build": "react-scripts build",
15+
"eject": "react-scripts eject"
16+
}
17+
}

0 commit comments

Comments
 (0)