https://github.com/tobi-de/litestar-tailwind-cli
Provides a CLI plugin for Litestar to use Tailwind CSS via the Tailwind CLI.
https://github.com/tobi-de/litestar-tailwind-cli
litestar tailwindcss
Last synced: 5 months ago
JSON representation
Provides a CLI plugin for Litestar to use Tailwind CSS via the Tailwind CLI.
- Host: GitHub
- URL: https://github.com/tobi-de/litestar-tailwind-cli
- Owner: Tobi-De
- License: mit
- Created: 2024-06-10T18:15:44.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-09-05T09:50:04.000Z (8 months ago)
- Last Synced: 2024-11-18T14:57:49.617Z (5 months ago)
- Topics: litestar, tailwindcss
- Language: CSS
- Homepage: https://github.com/Tobi-De/litestar-tailwind-cli
- Size: 38.1 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# litestar-tailwind-cli
[](https://pypi.org/project/litestar-tailwind-cli)
[](https://pypi.org/project/litestar-tailwind-cli)-----
> [!IMPORTANT]
> This plugin currently contains minimal features and is a work-in-progressProvides a CLI plugin for [Litestar](https://litestar.dev) to use [Tailwind CSS](https://tailwindcss.com) via the Tailwind CLI.
## Table of Contents
- [litestar-tailwind-cli](#litestar-tailwind-cli)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)## Installation
```console
pip install litestar-tailwind-cli
```## Usage
Configure and include the `TailwindCLIPlugin` in your Litestar app:
```python
from pathlib import Pathfrom 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 TailwindCLIPluginASSETS_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,
),
)
``````jinja
...
```
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 set `use_server_lifespan` to `True`.
- `litestar tailwind build`: This command builds a minified production-ready CSS file.> [!NOTE]
> Don't forget to update the `content` key in `tailwind.config.js` to specify your templates directories.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 to `False`. It will start the Tailwind CLI in watch mode when you use the `litestar run` command.
- `cli_version`: The version of the Tailwind CLI to download. Defaults to "latest".
- `src_repo`: The GitHub repository from which to download the Tailwind CLI. Defaults to `tailwindlabs/tailwindcss`.
- `asset_name`: The name of the asset to download from the repository. Defaults to `tailwindcss`.For example, if you are using the repository `https://github.com/dobicinaitis/tailwind-cli-extra/tree/main`, you would set `src_repo` to `"dobicinaitis/tailwind-cli-extra"` and `asset_name` to `"tailwindcss-extra"`.
## License
`litestar-tailwind-cli` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.