File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 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!
Original file line number Diff line number Diff line change @@ -220,3 +220,7 @@ $ python manage.py runserver
220220Now 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
222222The 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 )
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments