You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+45-7Lines changed: 45 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,10 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
6
6
7
7
Django-Tailwind is a Python package that integrates Tailwind CSS with Django applications. It provides management commands, template tags, and utilities to streamline Tailwind CSS development within Django projects.
8
8
9
+
The package supports two installation modes:
10
+
-**npm-based:** Traditional approach using Node.js and npm for maximum flexibility (plugins, PostCSS, etc.)
11
+
-**Standalone binary:** Simplified approach using the Tailwind CSS standalone binary via pytailwindcss (no Node.js required)
-`TAILWIND_USE_STANDALONE_BINARY` - Force standalone binary mode (default: False, auto-detected)
131
+
-`TAILWIND_STANDALONE_BINARY_VERSION` - Tailwind CSS standalone binary version (default: "v4.1.16")
132
+
133
+
### Standalone Binary Implementation
134
+
135
+
The standalone binary mode uses [pytailwindcss](https://github.com/timonweb/pytailwindcss) to run the Tailwind CSS standalone binary without requiring Node.js.
136
+
137
+
**How it works:**
138
+
1. Detection happens in the management command via `self.is_standalone` flag
139
+
2. Checks for `TAILWIND_USE_STANDALONE_BINARY` setting OR absence of `package.json`
140
+
3. Routes command execution to either npm methods or standalone methods
141
+
142
+
**Commands behavior:**
143
+
-`init --tailwind-version 4s`: Creates standalone app using `app_template_v4_standalone`
144
+
-`install`: Downloads standalone binary via pytailwindcss (auto-install on first use)
145
+
-`build`: Runs `pytailwindcss.run()` with minify flag
146
+
-`start`: Runs `pytailwindcss.run()` with watch flag
147
+
-`dev`: Works with standalone mode (Procfile uses `tailwind start`)
148
+
-`check-updates`, `update`, `plugin_install`: Raise CommandError (not supported in standalone)
149
+
150
+
**Key implementation methods in `tailwind.py`:**
151
+
-`tailwind_cli_install_command()`: Downloads binary via pytailwindcss
152
+
-`tailwind_cli_build_command()`: Builds CSS with standalone binary
153
+
-`tailwind_cli_start_command()`: Starts watcher with standalone binary
Copy file name to clipboardExpand all lines: docs/plugins.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,16 @@
1
1
# Installing Tailwind CSS Plugins
2
2
3
+
> **Important:** Plugin installation via the `plugin_install` command is **only available for npm-based installations**. If you're using the standalone binary mode (initialized with `--tailwind-version 4s`), the `plugin_install` command is not supported. Standalone installations are limited to core Tailwind CSS features only.
4
+
3
5
Django Tailwind provides built-in support for managing Tailwind CSS plugins. This guide covers how to install, configure, and manage plugins in your Tailwind CSS projects.
4
6
5
7
## Overview
6
8
7
9
Tailwind CSS plugins extend the framework's functionality by adding new utilities, components, and base styles. Django Tailwind makes it easy to install and configure these plugins through management commands.
Please refer to the [Installation](installation.md) section for more information on the installation process.
12
12
13
-
## `TAILWIND_DEV_MODE` (deprecated)
14
-
Determines whether the `browser-sync` snippet is added to the page via the `{% tailwind_css %}` tag. It is set to `False` by default. If you use a legacy pre-`3.1.0` configuration and rely on `browser-sync`, add `TAILWIND_DEV_MODE=True` to your `settings.py`.
13
+
## `NPM_BIN_PATH` (npm-based installation only)
14
+
15
+
> **Note:** This setting only applies to npm-based installations. Skip if using the standalone binary mode.
15
16
16
-
## `NPM_BIN_PATH`
17
17
This defines the path to the `npm` executable on your system.
18
18
19
19
> *Tailwind CSS* requires you to have *Node.js* installed on your machine.
@@ -32,6 +32,98 @@ Please note that on *Windows* the path might look different (pay attention to th
32
32
NPM_BIN_PATH=r"C:\Program Files\nodejs\npm.cmd"
33
33
```
34
34
35
+
## `TAILWIND_USE_STANDALONE_BINARY`
36
+
37
+
This setting determines whether to use the Tailwind CSS standalone binary instead of npm-based installation.
38
+
39
+
The default value is:
40
+
```python
41
+
TAILWIND_USE_STANDALONE_BINARY=False
42
+
```
43
+
44
+
When set to `True`, Django Tailwind will use the [pytailwindcss](https://github.com/timonweb/pytailwindcss) package to run the Tailwind CSS standalone binary. This eliminates the need for Node.js and npm.
45
+
46
+
> **Note:** In most cases, you don't need to set this manually. Django Tailwind automatically detects standalone installations by checking for the presence of `package.json` in your theme app. If you initialized your app with `--tailwind-version 4s`, this detection happens automatically.
47
+
48
+
To explicitly enable standalone mode:
49
+
50
+
```python
51
+
# settings.py
52
+
TAILWIND_USE_STANDALONE_BINARY=True
53
+
```
54
+
55
+
## `TAILWIND_STANDALONE_BINARY_VERSION`
56
+
57
+
This setting specifies which version of the Tailwind CSS standalone binary to use.
58
+
59
+
The default value is:
60
+
```python
61
+
TAILWIND_STANDALONE_BINARY_VERSION="v4.1.16"
62
+
```
63
+
64
+
You can specify any valid Tailwind CSS version tag. To upgrade to a newer version:
65
+
66
+
```python
67
+
# settings.py
68
+
TAILWIND_STANDALONE_BINARY_VERSION="v4.2.0"
69
+
```
70
+
71
+
After changing this setting, run `python manage.py tailwind install` to download the new binary version.
72
+
73
+
> **Note:** This setting only applies when using standalone binary mode. For npm-based installations, the version is controlled by the `package.json` file in your theme app.
74
+
75
+
**Finding available versions:**
76
+
77
+
Visit the [Tailwind CSS releases page](https://github.com/tailwindlabs/tailwindcss/releases) to see all available versions. Use the tag name (e.g., `v4.1.16`) as the value for this setting.
78
+
79
+
## `TAILWIND_STANDALONE_START_COMMAND_ARGS`
80
+
81
+
> **Note:** This setting only applies when using standalone binary mode.
82
+
83
+
This setting defines the command-line arguments passed to the Tailwind CSS standalone binary when running in watch mode (via `python manage.py tailwind start`).
> **Note:** The output path automatically uses the value from `TAILWIND_CSS_PATH` in the default configuration. If you override this setting, ensure your paths are correct.
102
+
103
+
## `TAILWIND_STANDALONE_BUILD_COMMAND_ARGS`
104
+
105
+
> **Note:** This setting only applies when using standalone binary mode.
106
+
107
+
This setting defines the command-line arguments passed to the Tailwind CSS standalone binary when building for production (via `python manage.py tailwind build`).
> **Note:** The output path automatically uses the value from `TAILWIND_CSS_PATH` in the default configuration. If you override this setting, ensure your paths match your project structure.
126
+
35
127
## `TAILWIND_CSS_PATH`
36
128
This defines the path to the generated *Tailwind CSS* stylesheet. If you created a theme app via the `python manage.py tailwind init` command, you likely don't need to change this value.
37
129
@@ -41,3 +133,6 @@ The default value is:
41
133
```python
42
134
TAILWIND_CSS_PATH="css/dist/styles.css"
43
135
```
136
+
137
+
## `TAILWIND_DEV_MODE` (deprecated)
138
+
Determines whether the `browser-sync` snippet is added to the page via the `{% tailwind_css %}` tag. It is set to `False` by default. If you use a legacy pre-`3.1.0` configuration and rely on `browser-sync`, add `TAILWIND_DEV_MODE=True` to your `settings.py`.
0 commit comments