-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathbuild.rake
39 lines (32 loc) · 1.42 KB
/
build.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace :tailwindcss do
desc "Build your Tailwind CSS"
task build: :environment do |_, args|
debug = args.extras.include?("debug")
verbose = args.extras.include?("verbose")
command = Tailwindcss::Commands.compile_command(debug: debug)
env = Tailwindcss::Commands.command_env(verbose: verbose)
puts "Running: #{Shellwords.join(command)}" if verbose
system(env, *command, exception: true)
end
desc "Watch and build your Tailwind CSS on file changes"
task watch: :environment do |_, args|
debug = args.extras.include?("debug")
poll = args.extras.include?("poll")
always = args.extras.include?("always")
verbose = args.extras.include?("verbose")
command = Tailwindcss::Commands.watch_command(always: always, debug: debug, poll: poll)
env = Tailwindcss::Commands.command_env(verbose: verbose)
puts "Running: #{Shellwords.join(command)}" if verbose
system(env, *command)
rescue Interrupt
puts "Received interrupt, exiting tailwindcss:watch" if args.extras.include?("verbose")
end
end
Rake::Task["assets:precompile"].enhance(["tailwindcss:build"])
if Rake::Task.task_defined?("test:prepare")
Rake::Task["test:prepare"].enhance(["tailwindcss:build"])
elsif Rake::Task.task_defined?("spec:prepare")
Rake::Task["spec:prepare"].enhance(["tailwindcss:build"])
elsif Rake::Task.task_defined?("db:test:prepare")
Rake::Task["db:test:prepare"].enhance(["tailwindcss:build"])
end