您忘记放入{% render_bundle 'back_office' 'js' %}
html 文件部分的正文
你的文件可能看起来像这样
{% load render_bundle from webpack_loader %}
{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- YOU COULD INCLUDE STATIC CSS FILES LIKE ... -->
<link rel="stylesheet" type="text/css" href='{% static "/css/fontawesome5.8.1/all.min.css" %}'>
<link rel="stylesheet" type="text/css" href='{% static "/css/bootstrap4.3.1/bootstrap.min.css" %}'>
<title>YOUR TITLE</title>
{% render_bundle 'first_entry_point' 'css' %}
</head>
<body>
<!-- YOU COULD INCLUDE STATIC JS FILES LIKE JQUERY ... -->
<script src='{% static "/js/jquery-3.4.1.min.js" %}' type="text/javascript"></script>
<script src='{% static "/js/bootstrap4.3.1/bootstrap.bundle.min.js" %}' type="text/javascript"></script>
<div id="react-app" style="height:100%;"></div>
{% render_bundle 'first_entry_point' 'js' %}
</body>
</html>
在webpack.config.js
你可以有像这样的入口点
.
.
.
module.exports = {
mode: "development",
entry: {
first_entry_point: path.join(__dirname, "...first_entry_point..."),
second_entry_point: path.join(__dirname, "...second_entry_point...")
},
.
.
.