Skip to content

Commit 6ce697a

Browse files
authored
Merge pull request markfinger#67 from anantzoid/webpack
Frontend(webpack) example's usage explanation extended, and webpack prod bundling scipt
2 parents c01d540 + bac67b3 commit 6ce697a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

examples/frontend-rendering-with-webpack/README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,26 @@ As mentioned in the ***Using React on the front-end*** section, [Webpack](https:
55

66
In this example, the basic_rendering example is modified to submit the Comment Form through ajax and update the Comment List by fetching the updated comments and rendering the application with new props.
77

8+
### Usage
89
Install the dependencies
910

1011
```
1112
pip install -r requirements.txt
1213
npm install
1314
```
14-
15-
Start the render server
16-
15+
### Usage in development
16+
Extending the explanation in the [README](https://github.com/markfinger/python-react/blob/master/README.md#usage-in-development) section of the repo, restarting the render server everytime a change is made in the `.jsx` files can be avoided, by running:
1717
```
18-
node render_server.js
18+
npm run watch
1919
```
20-
21-
Start the python server
22-
20+
alongside the python dev server:
2321
```
2422
python example.py
2523
```
24+
The forever utility check for changes and restarts the `render_server` accordingly.
2625

27-
And visit [http://127.0.0.1:5000](http://127.0.0.1:5000)
28-
29-
30-
31-
26+
### Usage in production
27+
Node server can be hosted in multiple ways. Either in the same box as flask server, or elsewhere. One way is to run it as a supervisord job on the same server. The React app needs to bundled as production ready before deploying the python server. This bundle is included in the `base` template for the app to render again on the client side. For bundling, run:
28+
```
29+
npm run postinstall
30+
```

examples/frontend-rendering-with-webpack/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"private": true,
33
"scripts": {
4-
"watch": "webpack --watch & forever --watch --watchDirectory ./static/js/src ./render_server.js"
4+
"watch": "webpack --watch & forever --watch --watchDirectory ./static/js/src ./render_server.js",
5+
"postinstall": "webpack -p"
56
},
67
"dependencies": {
78
"babel-core": "^6.1.20",

0 commit comments

Comments
 (0)