Use tailwind cli to compile css instead of tailwind cdn (#132)

* implement feature
* use npm instead of cli
This commit is contained in:
Tricked
2025-10-18 13:47:59 +02:00
committed by GitHub
parent 75eb5378c8
commit 4e898087d4
8 changed files with 1158 additions and 3 deletions

5
.gitignore vendored
View File

@@ -109,4 +109,7 @@ dmypy.json
.venv .venv
.pytest_logs.log .pytest_logs.log
node_modules

View File

@@ -26,6 +26,12 @@ Some useful scripts are in the `scripts` directory. If you run Linux (or WSL und
You can also run these commands manually on Windows: You can also run these commands manually on Windows:
##### Compiling css
To compile tailwind css styles for the pages you need the NodeJS and NPM installed.
You can run the `npm run css` script to generate the css once and you can run the `npm run css:watch` to recompile the css every time the templates change
##### Check ##### Check
``` ```
uv run ruff check uv run ruff check

View File

@@ -74,6 +74,11 @@ async def frontend_injection(hass: HomeAssistant, sso_name: str) -> None:
"/auth/oidc/static/injection.js", "/auth/oidc/static/injection.js",
hass.config.path("custom_components/auth_oidc/static/injection.js"), hass.config.path("custom_components/auth_oidc/static/injection.js"),
cache_headers=False, cache_headers=False,
),
StaticPathConfig(
"/auth/oidc/static/style.css",
hass.config.path("custom_components/auth_oidc/static/style.css"),
cache_headers=False,
) )
] ]
) )

View File

@@ -0,0 +1,3 @@
@import "tailwindcss";
@source "../views/templates";

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% endblock %}</title> <title>{% block title %}{% endblock %}</title>
<script src="https://cdn.tailwindcss.com"></script> <link rel="stylesheet" href="/auth/oidc/static/style.css">
{% endblock %} {% endblock %}
</head> </head>
@@ -16,4 +16,4 @@
</div> </div>
</body> </body>
</html> </html>

1125
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

11
package.json Normal file
View File

@@ -0,0 +1,11 @@
{
"name": "hass-oidc-auth",
"scripts": {
"css": "tailwindcss -i ./custom_components/auth_oidc/static/input.css -o ./custom_components/auth_oidc/static/style.css --minify",
"css:watch": "tailwindcss -i ./custom_components/auth_oidc/static/input.css -o ./custom_components/auth_oidc/static/style.css --watch --minify"
},
"dependencies": {
"@tailwindcss/cli": "^4.1.14",
"tailwindcss": "^4.1.14"
}
}