File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ def compile_command(debug: false, **kwargs)
6262 "-o" , Rails . root . join ( "app/assets/builds/tailwind.css" ) . to_s ,
6363 "-c" , Rails . root . join ( "config/tailwind.config.js" ) . to_s ,
6464 ] . tap do |command |
65- command << "--minify" unless debug
65+ command << "--minify" unless ( debug || rails_css_compressor? )
6666 end
6767 end
6868
@@ -72,6 +72,10 @@ def watch_command(poll: false, **kwargs)
7272 command << "-p" if poll
7373 end
7474 end
75+
76+ def rails_css_compressor?
77+ defined? ( Rails ) && Rails &.application &.config &.assets &.css_compressor . present?
78+ end
7579 end
7680 end
7781end
Original file line number Diff line number Diff line change 11namespace :tailwindcss do
22 desc "Build your Tailwind CSS"
3- task : build do |_ , args |
3+ task build : :environment do |_ , args |
44 debug = args . extras . include? ( "debug" )
55 command = Tailwindcss ::Commands . compile_command ( debug : debug )
66 puts command . inspect if args . extras . include? ( "verbose" )
77 system ( *command , exception : true )
88 end
99
1010 desc "Watch and build your Tailwind CSS on file changes"
11- task : watch do |_ , args |
11+ task watch : :environment do |_ , args |
1212 debug = args . extras . include? ( "debug" )
1313 poll = args . extras . include? ( "poll" )
1414 command = Tailwindcss ::Commands . watch_command ( debug : debug , poll : poll )
Original file line number Diff line number Diff line change @@ -58,6 +58,24 @@ def mock_exe_directory(platform)
5858 end
5959 end
6060
61+ test ".compile_command when Rails compression is on" do
62+ mock_exe_directory ( "sparc-solaris2.8" ) do |dir , executable |
63+ Rails . stub ( :root , File ) do # Rails.root won't work in this test suite
64+ Tailwindcss ::Commands . stub ( :rails_css_compressor? , true ) do
65+ actual = Tailwindcss ::Commands . compile_command ( exe_path : dir )
66+ assert_kind_of ( Array , actual )
67+ refute_includes ( actual , "--minify" )
68+ end
69+
70+ Tailwindcss ::Commands . stub ( :rails_css_compressor? , false ) do
71+ actual = Tailwindcss ::Commands . compile_command ( exe_path : dir )
72+ assert_kind_of ( Array , actual )
73+ assert_includes ( actual , "--minify" )
74+ end
75+ end
76+ end
77+ end
78+
6179 test ".watch_command" do
6280 mock_exe_directory ( "sparc-solaris2.8" ) do |dir , executable |
6381 Rails . stub ( :root , File ) do # Rails.root won't work in this test suite
You can’t perform that action at this time.
0 commit comments