Giter Site home page Giter Site logo

niicck / django-vite-examples Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 1.0 578 KB

Examples of how to use django-vite with multiple vue apps

License: GNU General Public License v3.0

Makefile 26.27% Dockerfile 31.51% Python 18.28% JavaScript 14.93% Shell 9.00%

django-vite-examples's Introduction

django-vite examples

Example Django apps showcasing how to use django-vite v3.

Install

All of the example demos run on Docker. Build the images with:

make build

Examples

1. Legacy Settings

This demo demonstrates backwards compatibility with legacy DJANGO_VITE_* settings from django-vite v2 and earlier versions.

Legacy Settings

2. New Settings (v3)

This demo shows how to run a single django-vite app using the new DJANGO_VITE={...} settings from django-vite v3 and higher. Everything else in the setup is identical to the legacy-settings demo.

Legacy Settings

3. Multi-App

This demo shows django-vite loading assets from 4 different vite apps.

Multi-App

This demo loads assets from 4 different vite apps:

  • The default app is running on a vite dev server with dev_mode=True.
  • vite_app_1 app is also running on a vite dev server with dev_mode=True.
  • vite_app_2 app has already been compiled in a production build. Those assets are being served from the STATIC_ROOT with dev_mode=False.
  • vite_app_3 app has also been compiled in a production build. Those assets are being served from the STATIC_ROOT with dev_mode=False.

Noteworthy differences between the multi-app setup and the other demos:

  • settings.py has the DJANGO_VITE settings that enable multiple apps.
  • index.html shows how to load assets from multiple vite apps.
  • vite_app_1/vite.config.js shows how I'm using static_url_prefix for directing build output and dev server routing.

Bug Report

There's 1 bug I've found with this demo: I'm not able to make HMR work on 2 different vite dev servers if they're both trying to update assets on the same page. Only one vite app will get changes registered to it in real time.

Realistically, a developer is unlikely to be working on more than 1 vite app with dev_mode=True on the same page. But it may still be worth investigating.

django-vite-examples's People

Contributors

niicck avatar

Stargazers

ashley revlett avatar pdina avatar John Gafnea avatar Cornelia P. avatar Stephan Fitzpatrick avatar James Flores avatar Holland Wilson avatar kimihito avatar Isaac Lewis avatar  avatar guusy! avatar Antonio Peña Batista avatar Iheanyi Oziegbe avatar

Watchers

 avatar

Forkers

paradox-lab2

django-vite-examples's Issues

Makefiles not working

Hi, I get various errors trying to run the makefiles. But cd-ing into the directory with the docker-compose file and then running docker-compose up works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.