Skip to content

Commit 359584d

Browse files
committed
Merge branch 'release/v0.4.1-preview5'
2 parents c4c1b9e + 9b07dc8 commit 359584d

File tree

8 files changed

+139
-6
lines changed

8 files changed

+139
-6
lines changed

.babelrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@
77
"plugins": [
88
"transform-runtime",
99
"transform-decorators-legacy"
10-
]
10+
],
11+
"env": {
12+
"production": {
13+
"plugins": [
14+
"transform-react-remove-prop-types",
15+
"transform-react-constant-elements",
16+
"transform-react-inline-elements"
17+
]
18+
}
19+
}
1120
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Packages:
3434
* [Generate component](./docs/generate-component.md)
3535
* [React-router howto](./docs/react-router-howto.md)
3636
* [How to create CRUD](./docs/crud.md)
37+
* [Configure and setup own server](./docs/local-server.md)
3738

3839
## Dependency docs
3940

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [Generate component](./generate-component.md)
1111
* [React-router howto](./react-router-howto.md)
1212
* [How to create CRUD](./crud.md)
13+
* [Configure and setup own server](./docs/local-server.md)
1314

1415
### Dependency
1516

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $ npm run build
6969
or, for a production build:
7070

7171
```shell
72-
$ npm run build -- --release
72+
$ BABEL_ENV=production npm run build -- --release
7373
```
7474

7575
After running this command, the `/build` folder will contain the compiled

docs/local-server.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
## Setup own server, without Docker and cloud-based solutions
2+
3+
This approach is relevant if you want to:
4+
5+
* speed up your dev-computer
6+
* deploy application on a dedicated server (or vps)
7+
* run app in corporate network
8+
9+
General scheme will looks like:
10+
```
11+
+------+ +------------+ +----------------+
12+
| user +---> | web server +----> | express server |
13+
+------+ +------------+ +----------------+
14+
```
15+
16+
First you need pre-installed and configured linux/nix system (not windows/osx).
17+
I will consider the example of ubuntu-server.
18+
19+
Install nvm (node version manager):
20+
21+
```
22+
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
23+
```
24+
25+
Then install Node.js 5.x, and setup default node version:
26+
```
27+
$ nvm install 5.4
28+
$ nvm alias default 5.4
29+
```
30+
31+
Then you need process manager for Node.js app server. This may be one of the:
32+
33+
* [pm2](https://github.com/Unitech/pm2)
34+
* [forever](https://github.com/foreverjs/forever)
35+
* other managers...
36+
37+
I chose `pm2`:
38+
```
39+
$ npm install pm2 -g
40+
```
41+
42+
Next you need build you app and upload on server, for example to `/var/www/myapp`
43+
(better to use git hooks or npm task for this).
44+
45+
```
46+
$ BABEL_ENV=production npm run build -- --release && rsync . to@my.host:/var/www/myapp
47+
```
48+
49+
If you app successfully loaded, configure you process manager and start application:
50+
51+
```shell
52+
web@server:/var/www/myapp# NODE_ENV=production PORT=5000 NAME=awesomeapp.com pm2 add --name "my-awesome-app" ./build/server.js
53+
54+
┌─────────────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐
55+
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
56+
├─────────────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤
57+
│ my-awesome-app │ 1 │ fork │ 777 │ online │ 0 │ 0m │ 7 MB │ disabled │
58+
└─────────────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘
59+
60+
```
61+
62+
Please note that we have specified `NODE_ENV=production` and other environment
63+
variables (NAME and PORT).
64+
65+
Next you need web server, such as:
66+
67+
* nginx
68+
* apache2
69+
* lighttpd
70+
* other web-servers..
71+
72+
Once you have installed the server, you will need to configure it.
73+
74+
Basic apache2 (with mod_proxy) configuration could look like this:
75+
```
76+
<VirtualHost *:80>
77+
ServerAdmin i@awesomeapp.com
78+
ServerName awesomeapp.com
79+
ServerAlias www.awesomeapp.com
80+
81+
ProxyRequests off
82+
83+
<Proxy *>
84+
Order deny,allow
85+
Allow from all
86+
</Proxy>
87+
88+
<Location />
89+
ProxyPass http://127.0.0.1:5000/
90+
ProxyPassReverse http://127.0.0.1:5000/
91+
</Location>
92+
93+
</VirtualHost>
94+
```
95+
96+
Basic nginx configuration:
97+
```
98+
upstream nodeserver {
99+
server 127.0.0.1:5000;
100+
}
101+
102+
server {
103+
listen 0.0.0.0:80;
104+
server_name awesomeapp.com;
105+
access_log /var/log/nginx/awesomeapp.com.log;
106+
107+
location / {
108+
proxy_set_header X-Real-IP $remote_addr;
109+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
110+
proxy_set_header Host $http_host;
111+
proxy_set_header X-NginX-Proxy true;
112+
113+
proxy_pass http://nodeserver/;
114+
proxy_redirect off;
115+
}
116+
}
117+
```
118+
119+
Setup and reload web server - now your application server is ready.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"dependencies": {
88
"alt": "^0.18.1",
99
"axios": "^0.9.1",
10-
"babel-plugin-transform-decorators-legacy": "^1.3.4",
1110
"babel-polyfill": "^6.5.0",
1211
"babel-runtime": "^6.5.0",
1312
"bluebird": "3.3.1",
@@ -43,6 +42,10 @@
4342
"babel-eslint": "^5.0.0",
4443
"babel-loader": "^6.2.3",
4544
"babel-plugin-react-transform": "^2.0.0",
45+
"babel-plugin-transform-decorators-legacy": "^1.3.4",
46+
"babel-plugin-transform-react-constant-elements": "^6.5.0",
47+
"babel-plugin-transform-react-inline-elements": "^6.5.0",
48+
"babel-plugin-transform-react-remove-prop-types": "^0.2.2",
4649
"babel-plugin-transform-runtime": "^6.5.2",
4750
"babel-preset-es2015": "^6.5.0",
4851
"babel-preset-react": "^6.5.0",
@@ -66,8 +69,8 @@
6669
"mkdirp": "^0.5.1",
6770
"ncp": "^2.0.0",
6871
"postcss": "^5.0.16",
69-
"postcss-import": "^8.0.2",
7072
"postcss-custom-media": "^5.0.0",
73+
"postcss-import": "^8.0.2",
7174
"postcss-loader": "^0.8.1",
7275
"precss": "^1.4.0",
7376
"raw-loader": "^0.5.1",

src/components/PrivatePage/PrivatePage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PrivatePage extends Component {
7070

7171
return (
7272
<div className={s.root}>
73-
<h1>This is example of prtected page</h1>
73+
<h1>This is example of protected page</h1>
7474
<p>You profile info:</p>
7575
<table>
7676
<tbody>

tools/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const clientConfig = extend(true, {}, config, {
113113
output: {
114114
path: path.join(__dirname, '../build/public'),
115115

116-
publicPath: DEBUG ? 'http://localhost:5000/' : '/',
116+
publicPath: DEBUG ? 'http://localhost:3000/' : '/',
117117

118118
filename: DEBUG ? '[name].js?[hash]' : '[name].[hash].js',
119119
},

0 commit comments

Comments
 (0)