Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## next / unreleased

### Changed

* Removed the "poll" option on the watch command, since Tailwind v4 dropped support for this option (and it has been a no-op in this gem since.) #580 @flavorjones


### Improved

* Support Rails 8.1 scaffolding which disables system tests by default. #585 @flavorjones
Expand Down
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Tailwind CSS for Rails

[Tailwind CSS](https://tailwindcss.com) is a utility-first CSS framework packed with classes like flex, pt-4, text-center and rotate-90 that can be composed to build any design, directly in your markup.
[Tailwind CSS](https://tailwindcss.com) is a utility-first CSS framework packed with classes like `flex`, `pt-4`, `text-center` and `rotate-90` that can be composed to build any design, directly in your markup.

> [!NOTE]
> This document is specific to Tailwind v4, corresponding to v4 of this gem. If you are looking for documentation for v3, please visit to the [tailwindcss-rails v3
README](https://github.com/rails/tailwindcss-rails/tree/v3-stable?tab=readme-ov-file).

<!-- regenerate TOC with `rake format:toc` -->

Expand Down Expand Up @@ -262,12 +266,13 @@ Synopsis:
- `bin/rails tailwindcss:install` - installs the configuration file, output file, and `Procfile.dev`
- `bin/rails tailwindcss:build` - generate the output file
- `bin/rails tailwindcss:build[debug]` - generate unminimized output
- `bin/rails tailwindcss:build[verbose]` - emit the commands being run
- `bin/rails tailwindcss:watch` - start live rebuilds, generating output on file changes
- `bin/rails tailwindcss:watch[debug]` - generate unminimized output
- `bin/rails tailwindcss:watch[poll]` - for systems without file system events
- `bin/rails tailwindcss:watch[always]` - for systems without TTY (e.g., some docker containers)
- `bin/rails tailwindcss:watch[verbose]` - emit the commands being run

Note that you can combine task options, e.g. `rails tailwindcss:watch[debug,poll]`.
Note that you can combine task options, e.g. `rails tailwindcss:watch[debug,always]`.

This gem also makes available a Puma plugin to manage a live rebuild process when you run `rails server` (see "Live Rebuild" section below).

Expand Down Expand Up @@ -312,14 +317,6 @@ and then running `rails server` (or just `puma`) will run the Tailwind watch pro

This is a flexible command, which can be run with a few different options.

If you are running `rails tailwindcss:watch` on a system that doesn't fully support file system events, pass a `poll` argument to the task to instruct tailwindcss to instead use polling:

```
rails tailwindcss:watch[poll]
```

(If you use `bin/dev` then you should modify your `Procfile.dev` to use the `poll` option.)

If you are running `rails tailwindcss:watch` as a process in a Docker container, set `tty: true` in `docker-compose.yml` for the appropriate container to keep the watch process running.

If you are running `rails tailwindcss:watch` in a docker container without a tty, pass the `always` argument to the task to instruct tailwindcss to keep the watcher alive even when `stdin` is closed: `rails tailwindcss:watch[always]`. If you use `bin/dev` then you should modify your `Procfile.dev`.
Expand Down
3 changes: 1 addition & 2 deletions lib/tailwindcss/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ def compile_command(debug: false, **kwargs)
command
end

def watch_command(always: false, poll: false, **kwargs)
def watch_command(always: false, **kwargs)
compile_command(**kwargs).tap do |command|
command << "-w"
command << "always" if always
command << "-p" if poll
end
end

Expand Down
3 changes: 1 addition & 2 deletions lib/tasks/build.rake
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ namespace :tailwindcss do
desc "Watch and build your Tailwind CSS on file changes"
task watch: [:environment, :engines] do |_, args|
debug = args.extras.include?("debug")
poll = args.extras.include?("poll")
always = args.extras.include?("always")
verbose = args.extras.include?("verbose")

command = Tailwindcss::Commands.watch_command(always: always, debug: debug, poll: poll)
command = Tailwindcss::Commands.watch_command(always: always, debug: debug)
env = Tailwindcss::Commands.command_env(verbose: verbose)
puts "Running: #{Shellwords.join(command)}" if verbose

Expand Down
8 changes: 0 additions & 8 deletions test/lib/tailwindcss/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,6 @@ def setup
refute_includes(actual, "-p")
refute_includes(actual, "--minify")

actual = Tailwindcss::Commands.watch_command(poll: true)
assert_kind_of(Array, actual)
assert_equal(executable, actual.first)
assert_includes(actual, "-w")
refute_includes(actual, "always")
assert_includes(actual, "-p")
assert_includes(actual, "--minify")

actual = Tailwindcss::Commands.watch_command(always: true)
assert_kind_of(Array, actual)
assert_equal(executable, actual.first)
Expand Down