djvite


Namedjvite JSON
Version 1.2.0 PyPI version JSON
download
home_pageNone
SummaryIntegrates Vite resources into a Django web site.
upload_time2025-01-27 13:39:13
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT License
keywords django javascript vite vue.js
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            DjVite
======

![logo](./djvite.svg)

Integrates [Vite](https://vite.dev/) resources into a [Django](https://www.djangoproject.com/) web site.

Web requests are first served through **vite** dev server, then either proxified to **django** dev server or served directly.

This simulates a **nginx** proxy and **wsgi** server.

How to use
----------

- Add `djvite` to your `INSTALLED_APPS` django config.
- Define your static directories:
```python
STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / 'static'
STATICFILES_DIRS = ['dist']
```
- Load the `djvite` plugin into your templates:
```html
<html>{% load djvite %}
...
</html>
```
- Inject any *script* or *link* from *vite* into your template:
    - `{% vite hotreload %}` enables vite hot module reload in dev mode
    - `{% vite '/src/main.js' %}`
    - `{% vite '/src/style.css' %}`
- Add `DjVitePlugin` to your `vite.config.js` file:
```javascript
import { defineConfig } from 'vite'
import DjVitePlugin from 'djvite'
export default defineConfig({
  plugins: [DjVitePlugin({verbose: true})],
})
```

Notes:

You can add any attributes to the `vite` tag and it will be added to the final tags.

You can specifiy multiple sources within one `vite` tag, separate them with spaces.

You can use the `get_nginx_config` command to generate a working nginx static configuration.

Configuration
-------------

In **django** settings:
- `DJVITE` dict, with the following keys:
  - `DEV_MODE` (boolean, default `True`)
  When `False`, resources are resolved using the `vite-manifest.json` file that list bundle files. This file is generated using `vite build`.
  - `VITE_MANIFEST_PATH` (`Path | str`, default to `vite.manifest.json`)
  Location to search for the Vite manifest. Used when `DEV_MODE` is `False`.

In **vite** config plugin:
- `options` object for `DjVitePlugin`.
    - `verbose` default to `false`.
    - `djangoPort` default to `DJANGO_PORT` environment variable or `8000` if not defined.
    - `djangoTemplatesGlob` default to the globbing pattern `**/templates`.
    - `manifestPath` default to `vite.manifest.json`.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "djvite",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "django, javascript, vite, vue.js",
    "author": null,
    "author_email": "Cyrille Pontvieux <cyrille@enialis.net>",
    "download_url": "https://files.pythonhosted.org/packages/cf/6e/e3e6a5307f198436dd258c6a492cf9c501746855f3d8293d08413bff7567/djvite-1.2.0.tar.gz",
    "platform": null,
    "description": "DjVite\n======\n\n![logo](./djvite.svg)\n\nIntegrates [Vite](https://vite.dev/) resources into a [Django](https://www.djangoproject.com/) web site.\n\nWeb requests are first served through **vite** dev server, then either proxified to **django** dev server or served directly.\n\nThis simulates a **nginx** proxy and **wsgi** server.\n\nHow to use\n----------\n\n- Add `djvite` to your `INSTALLED_APPS` django config.\n- Define your static directories:\n```python\nSTATIC_URL = \"static/\"\nSTATIC_ROOT = BASE_DIR / 'static'\nSTATICFILES_DIRS = ['dist']\n```\n- Load the `djvite` plugin into your templates:\n```html\n<html>{% load djvite %}\n...\n</html>\n```\n- Inject any *script* or *link* from *vite* into your template:\n    - `{% vite hotreload %}` enables vite hot module reload in dev mode\n    - `{% vite '/src/main.js' %}`\n    - `{% vite '/src/style.css' %}`\n- Add `DjVitePlugin` to your `vite.config.js` file:\n```javascript\nimport { defineConfig } from 'vite'\nimport DjVitePlugin from 'djvite'\nexport default defineConfig({\n  plugins: [DjVitePlugin({verbose: true})],\n})\n```\n\nNotes:\n\nYou can add any attributes to the `vite` tag and it will be added to the final tags.\n\nYou can specifiy multiple sources within one `vite` tag, separate them with spaces.\n\nYou can use the `get_nginx_config` command to generate a working nginx static configuration.\n\nConfiguration\n-------------\n\nIn **django** settings:\n- `DJVITE` dict, with the following keys:\n  - `DEV_MODE` (boolean, default `True`)\n  When `False`, resources are resolved using the `vite-manifest.json` file that list bundle files. This file is generated using `vite build`.\n  - `VITE_MANIFEST_PATH` (`Path | str`, default to `vite.manifest.json`)\n  Location to search for the Vite manifest. Used when `DEV_MODE` is `False`.\n\nIn **vite** config plugin:\n- `options` object for `DjVitePlugin`.\n    - `verbose` default to `false`.\n    - `djangoPort` default to `DJANGO_PORT` environment variable or `8000` if not defined.\n    - `djangoTemplatesGlob` default to the globbing pattern `**/templates`.\n    - `manifestPath` default to `vite.manifest.json`.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Integrates Vite resources into a Django web site.",
    "version": "1.2.0",
    "project_urls": {
        "Bug Tracker": "https://gitlab.com/jrdasm/djvite/-/issues",
        "Changelog": "https://gitlab.com/jrdasm/djvite/-/blob/master/CHANGELOG.md",
        "Contributing": "https://gitlab.com/jrdasm/djvite/-/blob/master/CONTRIBUTING.md",
        "Documentation": "https://gitlab.com/jrdasm/djvite/-/blob/master/README.md",
        "Merge Requests": "https://gitlab.com/jrdasm/djvite/-/merge_requests",
        "Repository": "https://gitlab.com/jrdasm/djvite"
    },
    "split_keywords": [
        "django",
        " javascript",
        " vite",
        " vue.js"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f1a7ab0c7f8a1cfa5680878c1461b3e840c2b75d56a8144ef74db50b8326ceca",
                "md5": "9ab4c2456f3a76e49bd9555bf36905c8",
                "sha256": "acbd2e701e0c0af09f294062e79e59f4dc5e6dad2c138b3a47a774848349e59d"
            },
            "downloads": -1,
            "filename": "djvite-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9ab4c2456f3a76e49bd9555bf36905c8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 9092,
            "upload_time": "2025-01-27T13:39:11",
            "upload_time_iso_8601": "2025-01-27T13:39:11.082946Z",
            "url": "https://files.pythonhosted.org/packages/f1/a7/ab0c7f8a1cfa5680878c1461b3e840c2b75d56a8144ef74db50b8326ceca/djvite-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cf6ee3e6a5307f198436dd258c6a492cf9c501746855f3d8293d08413bff7567",
                "md5": "ee1289b1ca3420fc7166f237127eb60f",
                "sha256": "111a7d75c07a6b8eb064e85bbc5f98175ef9dc02192c83c77fcc2a5b6857cb6e"
            },
            "downloads": -1,
            "filename": "djvite-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ee1289b1ca3420fc7166f237127eb60f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 7094,
            "upload_time": "2025-01-27T13:39:13",
            "upload_time_iso_8601": "2025-01-27T13:39:13.708122Z",
            "url": "https://files.pythonhosted.org/packages/cf/6e/e3e6a5307f198436dd258c6a492cf9c501746855f3d8293d08413bff7567/djvite-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-27 13:39:13",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "jrdasm",
    "gitlab_project": "djvite",
    "lcname": "djvite"
}
        
Elapsed time: 0.41312s