I have built a fairly simple web app in Vuejs, which was running with its default npm run dev command with webpack. Vue app was utilizing the api from Django that I have built using django-rest-framework. And whenever there was a change in Vue app it will automatically hot reload, which is pretty awesome.
Now I would like run the Vue app using django instead of webpack. What I mean is that Django will respond with an html template file, and Vuejs app will run on that html file for a single page application.
What I am doing now is first run this command:
npm run build
Then I copy the dist/static/ folder files into the django static folder. And finally load it into the template:
index.html
{% load static %}
<!DOCTYPE html>
<html>
<head>
...
...
<link href="{% static "css/app.e446b60204fec1f9f5510c711523ffca.css" %}" rel=stylesheet>
</head>
<body>
<div id="app"></div>
<script src="{% static "js/manifest.88376ea5d07804f39ff7.js" %}"></script>
<script src="{% static "js/vendor.e0e5105739e9947a23e7.js" %}"></script>
<script src="{% static "js/app.571e9140518a5bae898c.js" %}"></script>
</body>
</html>
Now later on, if I need to change the Vue app, I have to build it again, copy the files and load it inside the template, which seems pretty lengthy.
So, I am hoping there is better and short way to mix up both Django and Vuejs.
npm run buildto put the files straight into your django static folder, since there's really no benefit to putting them in the dist/static folder and then transferring them. I'm not really sure why the generated filenames wouldn't always be the same, which would mean you shouldn't have to change your template at all. I'm rather new to Vue myself, but hope this helps!django-webpack-buildermight help you.