【问题标题】:Update changes on React + Django without running "npm run build" everytime更新 React + Django 上的更改,而无需每次都运行“npm run build”
【发布时间】:2021-02-09 04:19:15
【问题描述】:

至少在大多数情况下,我的 Django + React 应用程序集成得很好。因为每次我必须对我的 React 代码进行更改时,为了应用这些更改,我必须停止 django 运行,然后每次运行 npm run build。

我已经阅读了此is there any way to run React + Django in same project without running npm run build again and again? 并尝试将其应用于我的问题,但没有奏效。

在 React 中还是新手,但对 Django 有一些经验。非常感谢您的帮助

【问题讨论】:

标签: reactjs django django-react


【解决方案1】:

在使用 Django 开发和 react 时,我经常发现通过提供给前端的 html 中的脚本标签来导入库(通常是缩小版本)更容易,这完全避免了完全使用 npm 的需要。如果您确实切换到此方法,只需确保将 debug 设置为 true 并且您将能够通过运行“python manage.py runserver”来启动服务器,并且您将能够访问您在 Django 端口上的所有内容正在使用。

【讨论】:

    猜你喜欢
    • 2020-06-10
    • 2020-11-28
    • 1970-01-01
    • 2022-12-21
    • 2020-10-16
    • 2021-12-01
    • 2020-08-21
    • 2019-11-15
    • 2021-05-20
    相关资源
    最近更新 更多