diff --git a/django_vite/templatetags/django_vite.py b/django_vite/templatetags/django_vite.py index 6e18ddb..fcdb8c4 100644 --- a/django_vite/templatetags/django_vite.py +++ b/django_vite/templatetags/django_vite.py @@ -120,7 +120,7 @@ def generate_vite_asset( if DJANGO_VITE_DEV_MODE: return DjangoViteAssetLoader._generate_script_tag( DjangoViteAssetLoader._generate_vite_server_url(path), - {"type": "module"}, + {"type": "module", **kwargs}, ) if not self._manifest or path not in self._manifest: @@ -345,7 +345,7 @@ def instance(cls): return cls._instance @classmethod - def generate_vite_ws_client(cls) -> str: + def generate_vite_ws_client(cls, **kwargs: Dict[str, str]) -> str: """ Generates the script tag for the Vite WS client for HMR. Only used in development, in production this method returns @@ -353,6 +353,10 @@ def generate_vite_ws_client(cls) -> str: Returns: str -- The script tag or an empty string. + + Keyword Arguments: + **kwargs {Dict[str, str]} -- Adds new attributes to generated + script tags. """ if not DJANGO_VITE_DEV_MODE: @@ -360,7 +364,7 @@ def generate_vite_ws_client(cls) -> str: return cls._generate_script_tag( cls._generate_vite_server_url(DJANGO_VITE_WS_CLIENT_URL), - {"type": "module"}, + {"type": "module", **kwargs}, ) @staticmethod @@ -468,7 +472,7 @@ def _generate_production_server_url(path: str) -> str: @register.simple_tag @mark_safe -def vite_hmr_client() -> str: +def vite_hmr_client(**kwargs: Dict[str, str]) -> str: """ Generates the script tag for the Vite WS client for HMR. Only used in development, in production this method returns @@ -476,9 +480,13 @@ def vite_hmr_client() -> str: Returns: str -- The script tag or an empty string. + + Keyword Arguments: + **kwargs {Dict[str, str]} -- Adds new attributes to generated + script tags. """ - return DjangoViteAssetLoader.generate_vite_ws_client() + return DjangoViteAssetLoader.generate_vite_ws_client(**kwargs) @register.simple_tag