Webpack Getting Variables

    {% load static %}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Django Webpack template</title>
  </head>
  <body>
    <div id="root"></div>
    
    <p id="message">Template Data</p>

    <script id="templateDataScript" type="application/json">
      {{ template_data|safe }}
    </script>
    <script src="{% static 'data.bundle.js' %}"></script>
  </body>
</html>

This seems to work file when I run it locally...

However, if I Webpack this and use my bundle file online it does not recognize the Django template_data. Trying to find out is it possible to somehow incorporate my variables and data into the Webpack itself.

Just searching for any insight.

Back to Top