You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### `src/app.node.js` - Server-side rendering and REST or GraphQL API
72
+
#### `src/app.node.js` - Server-side rendering and/or API endpoint
65
73
66
74
```js
67
-
importpathfrom'path';
68
-
importexpressfrom'express';
69
-
importReactfrom'react';
70
-
importReactDOMServerfrom'react-dom/server';
71
-
importAppfrom'./components/App';
72
-
importassetsfrom'./assets.json';
75
+
constpath=require('path');
76
+
constexpress=require('express');
77
+
constReact=require('react');
78
+
constReactDOMServer=require('react-dom/server');
79
+
constApp=require('./components/App');
80
+
constassets=require('./assets.json');
73
81
74
82
constapp=express();
75
83
@@ -84,15 +92,11 @@ app.get('*', (req, res) => {
84
92
`);
85
93
});
86
94
87
-
exportdefaultapp;
88
-
```
89
-
90
-
#### `src/server.js` - Server-side entry point
91
-
92
-
```js
93
-
importappfrom'./app.node';
94
-
95
-
app.listen(process.env.PORT||8080);
95
+
if (process.env.NODE_ENV==='production') {
96
+
app.listen(process.env.PORT||8080);
97
+
} else {
98
+
module.exports.default= app;
99
+
}
96
100
```
97
101
98
102
You can launch the app in development mode by running:
@@ -116,10 +120,10 @@ Join our Telegram chat for support and feature requests - https://t.me/reactapp
116
120
117
121
<palign="center"><ahref="https://www.youtube.com/watch?v=GH3kJwQ7mxM"><imgsrc="http://img.youtube.com/vi/GH3kJwQ7mxM/maxresdefault.jpg"width="1187"alt="Server-side rendering with React.js" /><br /><sup>How fast is React SSR?</sup></a></p>
118
122
119
-
###How to Customize
123
+
## How to Customize
120
124
121
-
Create `override.js` file in the root of your project containing configuration overrides.
122
-
For example:
125
+
Create `config-overrides.js` file in the root of your project containing with configuration
126
+
overrides. Here is an example:
123
127
124
128
```js
125
129
module.exports= {
@@ -140,14 +144,56 @@ module.exports = {
140
144
};
141
145
```
142
146
143
-
### Contribute
147
+
## Backers
148
+
149
+
Love **React App SDK**? Help us keep it alive by [donating](https://opencollective.com/react-app)
This package includes scripts and configuration used by [Create React App](https://github.com/facebook/create-react-app).<br>
4
-
Please refer to its documentation:
3
+
This package is a fork of [`react-scripts`](https://npmjs.com/package/react-scripts) that adds a
4
+
couple more features to [Create React App](https://github.com/facebook/create-react-app) tooling:
5
5
6
-
*[Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
7
-
*[User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
6
+
* An ability to add, build, and test server-side code using the same instance of Webpack.
7
+
* An ability to customize Babel, Webpack and other configs by putting `config-overrides.js`
8
+
file in the root of your project.
9
+
10
+
For more information visit:
11
+
12
+
*https://github.com/facebook/create-react-app - the original repository
13
+
*https://github.com/kriasoft/react-app - the patched version of CRA
0 commit comments