Skip to content

Commit 67a1015

Browse files
committed
add live reload doc
1 parent be5d1ea commit 67a1015

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

docs/live_reload.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Live Reload
2+
3+
With `webpack-dev-server`, we can use it to auto reload web page when the code of the project changed.
4+
5+
Please edit `frontend/webpack/webpack.config.dev.js`
6+
7+
```js
8+
devServer: {
9+
host: "0.0.0.0",
10+
port: 9091,
11+
headers: {
12+
"Access-Control-Allow-Origin": "*",
13+
},
14+
writeToDisk: true,
15+
watchFiles: [
16+
Path.join(__dirname, '../../django_app/**/*.py'),
17+
Path.join(__dirname, '../../django_app/**/*.html'),
18+
],
19+
},
20+
```
21+
22+
Notes:
23+
24+
1. Remove `inline: true,` and `hot: true` from the `devServer` section
25+
1. Then you should config the `watchFiles`
26+
1. Here we tell `webpack-dev-server` to watch all `.py` and `.html` files under the `django_app` directory.
27+
28+
Now if we change code in the editor, the web page will live reload, which is awesome!

docs/setup_with_django.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,7 @@ $ python manage.py runserver
220220
Now check on [http://127.0.0.1:8000/](http://127.0.0.1:8000/) and you should be able to see a welcome page.
221221

222222
The source code can also be found in the [Examples](https://github.com/AccordBox/python-webpack-boilerplate/tree/master/examples/)
223+
224+
## Live Reload
225+
226+
[Live Reload Support](live_reload)

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ nav:
1818
- Setup With Flask: setup_with_flask.md
1919
- Frontend workflow: frontend.md
2020
- Run NPM command at root directory: run_npm_command_at_root.md
21+
- Live Reload: live_reload.md
2122
- Tailwind CSS: setup_with_tailwind.md
2223
- Import React: react.md
2324
- Import Vue: vue.md

0 commit comments

Comments
 (0)