I want to serve my Vue application (as SPA) through django, and I passed across this article. The author use django-webpack-loader to achieve this, but is not adding a simple TemplateView around dist/index.html will do the job:
url(r'^app/', TemplateView.as_view(template_name='index.html'), name='app'),
also this require altering settings.by as follow:
'DIRS': [
BASE_DIR + "/templates/",
BASE_DIR + "/dist/",
]
My question is what is the role of django-webpack-loader in the process if the app is already build using vue-cli?
After trying my approach without
django-webpack-loader, I concluded that after each build, you have to do the following:index.html), in a place that django can find it.staticfolder.index.htmlso it can correctly locate and load the scripts and css files, e.g:Should be:
So
django-webpack-loadershould helps you with automating this task. without going through djangostaticfilessystem.Also I have read that
django-webpack-loadercan provide hot-code reloading during development but I did not try this out. Also I could not find information on howdjango-webpack-loaderworks really, so consider this answer incomplete.