File tree 3 files changed +25
-3
lines changed
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)
62
62
"-o" , Rails . root . join ( "app/assets/builds/tailwind.css" ) . to_s ,
63
63
"-c" , Rails . root . join ( "config/tailwind.config.js" ) . to_s ,
64
64
] . tap do |command |
65
- command << "--minify" unless debug
65
+ command << "--minify" unless ( debug || rails_css_compressor? )
66
66
end
67
67
end
68
68
@@ -72,6 +72,10 @@ def watch_command(poll: false, **kwargs)
72
72
command << "-p" if poll
73
73
end
74
74
end
75
+
76
+ def rails_css_compressor?
77
+ defined? ( Rails ) && Rails &.application &.config &.assets &.css_compressor . present?
78
+ end
75
79
end
76
80
end
77
81
end
Original file line number Diff line number Diff line change 1
1
namespace :tailwindcss do
2
2
desc "Build your Tailwind CSS"
3
- task : build do |_ , args |
3
+ task build : :environment do |_ , args |
4
4
debug = args . extras . include? ( "debug" )
5
5
command = Tailwindcss ::Commands . compile_command ( debug : debug )
6
6
puts command . inspect if args . extras . include? ( "verbose" )
7
7
system ( *command , exception : true )
8
8
end
9
9
10
10
desc "Watch and build your Tailwind CSS on file changes"
11
- task : watch do |_ , args |
11
+ task watch : :environment do |_ , args |
12
12
debug = args . extras . include? ( "debug" )
13
13
poll = args . extras . include? ( "poll" )
14
14
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)
58
58
end
59
59
end
60
60
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
+
61
79
test ".watch_command" do
62
80
mock_exe_directory ( "sparc-solaris2.8" ) do |dir , executable |
63
81
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