Helper Utilities for loading assets genated from Vite manifests
Project description
fastapi-vite
Integration for FastAPI and Vite JS
what?
This package is designed to make working with javascript assets easier.
fastapi-vite enables the jinja filters required to render asset URLs to jinja templates
installation
Install using pip
pip install fastapi-vite
Usage
Configure Jinja templating for FastAPI
templates = Jinja2Templates(directory='templates')
templates.env.globals['render_vite_hmr_client'] = fastapi_vite.render_vite_hmr_client
templates.env.globals['asset_url'] = fastapi_vite.asset_url
Configure Vite
Configure Static Assets
Configure Templates
*render_vite_hmr no-op when in production.
{{ render_vite_hmr_client() }}
<script
type="text/javascript"
defer
src="{{ asset_url('javascript/main.tsx') }}"
></script>
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
fastapi-vite-0.1.6.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_vite-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cc7a0a2bdb3f19859dda74db0651ef715595090c9bb72d3f5ae6cdcba349d18 |
|
MD5 | be88e0e311a609e2212afb2a1dbf3755 |
|
BLAKE2b-256 | bdeb7ec5cbde589f4c5194e3c0496cf21aa86ab38fa168377b5579dfe701ba9d |