Skip to main content

Vite build tools integration for django

Project description

Django Vite Plugin

PyPI version

Introduction

Vite is a modern frontend build tool that provides an extremely fast development environment and bundles your code for production.

This plugin configures Vite for use with Django backend.

Installation

pip install django_vite_plugin

Then in your projects settings.py file, add django_vite_plugin in installed apps

# Some settings
INSTALLED_APPS = [
    # Some apps
    'django_vite_plugin',
    # Other apps
]

These are the available configuration options

# Other settings
DJANGO_VITE_PLUGIN = {
    'WS_CLIENT': '@vite/client',
    'DEV_MODE': getattr(settings, 'DEBUG', True),
    'BUILD_DIR': getattr(settings, 'STATIC_ROOT') or 'static',
    'BUILD_URL_PREFIX': getattr(settings, 'STATIC_URL'), # Bundled assets would be prefixed with this on production
    'SERVER': {
        'HTTPS': False,
        'HOST': '127.0.0.1',
        'PORT': 5173
    },
    'JS_ATTRS': {
        'type': 'module'
    },
    'CSS_ATTRS': {
        'rel' : 'stylesheet',
        'type': 'text/css'
    },
    'STATIC_LOOKUP': True
}

See the official documentation for more details

Usage

<!--Your Template file-->
{% load vite %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <!--Other elements-->
        <!--Vite dev client for hmr (will not be displayed on production)-->
        {% vite %}
        <!--These attributes will be present in both `asset1.css` & `asset2.js`-->
        {% vite 'asset1.css' 'asset2.js' someattr='value' %}
    </head>
    <body>
        <!--Page content-->
    </body>
</html>

Official Documentation

Documentation for the Django Vite plugin can be found on the Github.

License

The Django Vite plugin is open-sourced software licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_vite_plugin-3.0.4.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

django_vite_plugin-3.0.4-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file django_vite_plugin-3.0.4.tar.gz.

File metadata

  • Download URL: django_vite_plugin-3.0.4.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for django_vite_plugin-3.0.4.tar.gz
Algorithm Hash digest
SHA256 e5964597daa53ad5992f23e99e61dc4168c07ed51077851a3e3f02989697d41c
MD5 0948f81dd36c20f47380d8a6622620bd
BLAKE2b-256 3aec24786da10b7d32906e99e22f6312333b51fb3d6322647d056ef090d99e64

See more details on using hashes here.

File details

Details for the file django_vite_plugin-3.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_vite_plugin-3.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5cc0425cd9a56afc0d1d27d5016e61a6929ad93024307af4195e4b25db340574
MD5 69a78cfe4e7fc7f41a47064d8c5f5a8e
BLAKE2b-256 5de04bc110d278d213d3dbccfac6d6f8ab229199d1876251eaa7e7f945de251a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page