Skip to content

Commit 8a91475

Browse files
committed
Take multiple input files, make multiple outputs.
1 parent 89e1b30 commit 8a91475

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

lib/tailwindcss/commands.rb

+8-4
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@ def executable(
5555
exe_path
5656
end
5757

58-
def compile_command(debug: false, **kwargs)
58+
def compile_command(debug: false,
59+
input: "app/assets/stylesheets/application.tailwind.css",
60+
output: "app/assets/builds/tailwind.css",
61+
config: "config/tailwind.config.js",
62+
**kwargs)
5963
[
6064
executable(**kwargs),
61-
"-i", Rails.root.join("app/assets/stylesheets/application.tailwind.css").to_s,
62-
"-o", Rails.root.join("app/assets/builds/tailwind.css").to_s,
63-
"-c", Rails.root.join("config/tailwind.config.js").to_s,
65+
"-i", Rails.root.join(input).to_s,
66+
"-o", Rails.root.join(output).to_s,
67+
"-c", Rails.root.join(config).to_s,
6468
].tap do |command|
6569
command << "--minify" unless debug
6670
end

lib/tasks/build.rake

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@ namespace :tailwindcss do
22
desc "Build your Tailwind CSS"
33
task :build do |_, args|
44
debug = args.extras.include?("debug")
5-
command = Tailwindcss::Commands.compile_command(debug: debug)
6-
puts command.inspect
7-
system(*command, exception: true)
5+
Dir['app/assets/stylesheets/**/*.tailwind.css'].each do | stylesheet |
6+
output = 'app/assets/builds/'+stylesheet.gsub('app/assets/stylesheets/', '').gsub('.tailwind', '')
7+
command = Tailwindcss::Commands.compile_command(debug: debug, input: stylesheet, output: output)
8+
puts command.inspect
9+
system(*command, exception: true)
10+
end
811
end
912

1013
desc "Watch and build your Tailwind CSS on file changes"
1114
task :watch do |_, args|
1215
debug = args.extras.include?("debug")
1316
poll = args.extras.include?("poll")
14-
command = Tailwindcss::Commands.watch_command(debug: debug, poll: poll)
15-
puts command.inspect
16-
system(*command)
17+
Dir['app/assets/stylesheets/**/*.tailwind.css'].each do | stylesheet |
18+
output = 'app/assets/builds/'+stylesheet.gsub('app/assets/stylesheets/', '').gsub('.tailwind', '')
19+
command = Tailwindcss::Commands.watch_command(debug: debug, poll: poll, input: stylesheet, output: output)
20+
puts command.inspect
21+
system(*command)
22+
end
1723
end
1824
end
1925

0 commit comments

Comments
 (0)