Skip to content

Commit bf09205

Browse files
committed
feat: support polling instead of fs events when watching
Polling was added upstream in 3.1.0. Suggested by #168
1 parent 4da93dd commit bf09205

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

Diff for: CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
## Unreleased
33

44
* Correctly handle paths with embedded spaces. [#184](https://github.com/rails/tailwindcss-rails/issues/184) by [@flavorjones](https://github.com/flavorjones)
5-
* Rake tasks accept a `debug` argument to generate unminified assets, e.g. `tailwindcss:build[debug]`. [#198](https://github.com/rails/tailwindcss-rails/pull/198) by [@flavorjones](https://github.com/flavorjones)
5+
* The `build` and `watch` tasks accept a `debug` argument to generate unminified assets: `rails tailwindcss:build[debug]` or `rails tailwindcss:watch[debug]`. [#198](https://github.com/rails/tailwindcss-rails/pull/198) by [@flavorjones](https://github.com/flavorjones)
6+
* The `watch` task accepts a `poll` argument to use polling instead of file system events: `rails tailwindcss:watch[poll]`. [#199](https://github.com/rails/tailwindcss-rails/pull/199) by [@flavorjones](https://github.com/flavorjones)
67

78

89
## v2.0.12 / 2022-08-10

Diff for: README.md

+5
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,15 @@ While you're developing your application, you want to run Tailwind in "watch" mo
4040

4141
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.
4242

43+
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`.
44+
45+
4346
### Debugging with unminified assets
4447

4548
If you want unminified assets, you can pass a `debug` argument to the rake task, i.e. `rails tailwindcss:build[debug]` or `rails tailwindcss:watch[debug]`.
4649

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

4853
### Custom inputs or outputs
4954

Diff for: lib/tailwindcss/commands.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ def compile_command(debug: false, **kwargs)
6666
end
6767
end
6868

69-
def watch_command(**kwargs)
70-
compile_command(**kwargs) << "-w"
69+
def watch_command(poll: false, **kwargs)
70+
compile_command(**kwargs).tap do |command|
71+
command << "-w"
72+
command << "-p" if poll
73+
end
7174
end
7275
end
7376
end

Diff for: lib/tasks/build.rake

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ namespace :tailwindcss do
1010
desc "Watch and build your Tailwind CSS on file changes"
1111
task :watch do |_, args|
1212
debug = args.extras.include?("debug")
13-
command = Tailwindcss::Commands.watch_command(debug: debug)
13+
poll = args.extras.include?("poll")
14+
command = Tailwindcss::Commands.watch_command(debug: debug, poll: poll)
1415
puts command.inspect
1516
system(*command)
1617
end

Diff for: test/lib/tailwindcss/commands_test.rb

+9
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,22 @@ def mock_exe_directory(platform)
6565
assert_kind_of(Array, actual)
6666
assert_equal(executable, actual.first)
6767
assert_includes(actual, "-w")
68+
refute_includes(actual, "-p")
6869
assert_includes(actual, "--minify")
6970

7071
actual = Tailwindcss::Commands.watch_command(exe_path: dir, debug: true)
7172
assert_kind_of(Array, actual)
7273
assert_equal(executable, actual.first)
7374
assert_includes(actual, "-w")
75+
refute_includes(actual, "-p")
7476
refute_includes(actual, "--minify")
77+
78+
actual = Tailwindcss::Commands.watch_command(exe_path: dir, poll: true)
79+
assert_kind_of(Array, actual)
80+
assert_equal(executable, actual.first)
81+
assert_includes(actual, "-w")
82+
assert_includes(actual, "-p")
83+
assert_includes(actual, "--minify")
7584
end
7685
end
7786
end

0 commit comments

Comments
 (0)