Provides a CLI plugin for Litestar to use Tailwind CSS via the Tailwind CLI.
Project description
litestar-tailwind-cli
[!IMPORTANT] This plugin currently contains minimal features and is a work-in-progress
Provides a CLI plugin for Litestar to use Tailwind CSS via the Tailwind CLI.
Table of Contents
Installation
pip install litestar-tailwind-cli
Usage
Configure and include the TailwindCLIPlugin
in your Litestar app:
from pathlib import Path
from litestar import Litestar
from litestar.static_files import create_static_files_router
from litestar.contrib.jinja import JinjaTemplateEngine
from litestar.template.config import TemplateConfig
from litestar_tailwind_cli import TailwindCLIPlugin
ASSETS_DIR = Path("assets")
tailwind_cli = TailwindCLIPlugin(
use_server_lifespan=True,
src_css=ASSETS_DIR / "css" / "input.css",
dist_css=ASSETS_DIR / "css" / "tailwind.css",
)
app = Litestar(
route_handlers=[create_static_files_router(path="/static", directories=["assets"])],
debug=True,
plugins=[tailwind_cli],
template_config=TemplateConfig(
directory=Path("templates"),
engine=JinjaTemplateEngine,
),
)
<head>
...
<link rel="stylesheet" href="{{ url_for('static', path='css/tailwind.css') }}">
</head>
After setting up, you can use the following commands:
litestar tailwind init
: This command initializes the tailwind configuration and downloads the CLI if it's not already installed.litestar tailwind watch
: This command starts the Tailwind CLI in watch mode during development. You won't have to use this if you setuse_server_lifespan
toTrue
.litestar tailwind build
: This command builds a minified production-ready CSS file.
The TailwindCLIPlugin
has the following configuration options:
src_css
: The path to the source CSS file. Defaults to "css/input.css".dist_css
: The path to the distribution CSS file. Defaults to "css/tailwind.css".config_file
: The path to the Tailwind configuration file. Defaults to "tailwind.config.js".use_server_lifespan
: Whether to use server lifespan. Defaults toFalse
. It will start the Tailwind CLI in watch mode when you use thelitestar run
command.cli_version
: The version of the Tailwind CLI to download. Defaults to "latest".
License
litestar-tailwind-cli
is distributed under the terms of the MIT license.
Project details
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 litestar_tailwind_cli-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5d95871e59192af714b8dbeca05b813166e8140e32128d7e50a806587cd77f3 |
|
MD5 | 802c9d7dc789d232c8046e947988e9a5 |
|
BLAKE2b-256 | 2acd858054bc21d88f49ee21e3b559fb647aca2ccf12c1c0ba6456dce91d0b88 |
Close
Hashes for litestar_tailwind_cli-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 639e27fb48b31425c78b25b27b01138b75bf93995374b3c346f5a201d0fc9154 |
|
MD5 | a64e97cd52b6d73b89bcb0d78c6b41cb |
|
BLAKE2b-256 | 331d27d438f19ed859ae5ecbe7ff83623bb2f50247473d031be1637335aa58b0 |