项目作者: rguliev

项目描述 :
This is a template for combining django+vue+webpack supporting dev and prod environments
高级语言: Python
项目地址: git://github.com/rguliev/django-vue-webpack-template.git
创建时间: 2019-05-30T15:34:33Z
项目社区:https://github.com/rguliev/django-vue-webpack-template

开源协议:MIT License

下载


:snake:Django + :heavy_check_mark:Vue + :large_blue_diamond:Webpack + :gear:.env

Story

I was searching for an example/template for combining django+vue+webpack. Althought there are many repos and posts on it, none of them covered different environments settings, multiplie pages, switching hotreload. Most of them used old vue-cli config. So I combined all that exmaples and added support for multiplie pages and .env settings.
If you know how to make it better, plase feel free to contribute.

Intallation

It is supposed that you have installed:

  1. # Clone the repo
  2. git clone https://github.com/rguliev/django-vue-webpack-template.git
  3. cd django-vue-webpack-template
  4. # Set your env
  5. cp .env.example .env
  6. # Install all backend dependencies
  7. pipenv install
  8. python manage.py makemigrations
  9. python manage.py migrate
  10. # Install all frontend dependencies
  11. cd frontend
  12. npm install

Run dev with hot-reload

  1. Set both django and node env to development:
    1. DJANGO_ENV=development
    2. NODE_ENV=development
  2. run in terminal: cd frontend && npm run serve
  3. run in another terminal: python manage.py runserver
  4. Open http://127.0.0.1:8000/

Run dev without hot-reload

  1. Set django to development and node to production:
    1. DJANGO_ENV=development
    2. NODE_ENV=production
  2. run in terminal:
    1. cd frontend
    2. npm run build
    3. cd ../
    4. python manage.py runserver
  3. Open http://127.0.0.1:8000/