0

main.css没有渲染,我在webpack.config.js文件中使用了多个入口点

% load render_bundle from webpack_loader %}
<!DOCTYPE html>
<html>
<head>
  <meta name='apple-mobile-web-app-capable' content='yes' />
  <meta itemprop='name' content='TableGrabber Dashboard'>
  {% render_bundle "main" "css" %}
  {% render_bundle "vendors~main" "css" %}
  <title>
    {{ title }}
  </title>

我希望我的两个 app.js 文件都会呈现,并且可以通过将 URL 放入浏览器中来运行其中写入的路由

4

1 回答 1

0

您忘记放入{% 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...")
  },
.
.
.
于 2019-06-25T17:16:47.810 回答