Skip to content

Tailwindcss debug environment variable #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add TAILWINDCSS_DEBUG environment variable
  • Loading branch information
r-sierra authored and flavorjones committed Feb 25, 2025
commit a1b37572a13ba11ce914e682dc5a1b390043e378
1 change: 1 addition & 0 deletions lib/tailwindcss/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Tailwindcss
module Commands
class << self
def compile_command(debug: false, **kwargs)
debug ||= ["true", "1"].include?(ENV["TAILWINDCSS_DEBUG"])
rails_root = defined?(Rails) ? Rails.root : Pathname.new(Dir.pwd)

command = [
Expand Down
28 changes: 28 additions & 0 deletions test/lib/tailwindcss/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,34 @@ def setup
end
end

test ".compile_command debug environment variable" do
begin
Rails.stub(:root, File) do # Rails.root won't work in this test suite
ENV["TAILWINDCSS_DEBUG"] = "0"
actual = Tailwindcss::Commands.compile_command
assert_kind_of(Array, actual)
assert_includes(actual, "--minify")

ENV["TAILWINDCSS_DEBUG"] = "1"
actual = Tailwindcss::Commands.compile_command
assert_kind_of(Array, actual)
refute_includes(actual, "--minify")

ENV["TAILWINDCSS_DEBUG"] = "false"
actual = Tailwindcss::Commands.compile_command
assert_kind_of(Array, actual)
assert_includes(actual, "--minify")

ENV["TAILWINDCSS_DEBUG"] = "true"
actual = Tailwindcss::Commands.compile_command
assert_kind_of(Array, actual)
refute_includes(actual, "--minify")
end
ensure
ENV.delete('TAILWINDCSS_DEBUG')
end
end

test ".compile_command when Rails compression is on" do
Rails.stub(:root, File) do # Rails.root won't work in this test suite
Tailwindcss::Commands.stub(:rails_css_compressor?, true) do
Expand Down