Vite build tools integration for django
Project description
Django Vite Plugin
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django_vite_plugin-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb76b20756f41af658715ceda45357d2a8dec481e0b049c0dc6ee494d640d5a0 |
|
MD5 | 34d80d6bc1fa4fe4b499738197dfc829 |
|
BLAKE2b-256 | abb8c77daba5db912ea3a2a9f77a5a3058de09e4a488efefe91e22c606f64d29 |