diff --git a/lib/bootic_cli/commands/themes.rb b/lib/bootic_cli/commands/themes.rb index 71ead81..04b9098 100644 --- a/lib/bootic_cli/commands/themes.rb +++ b/lib/bootic_cli/commands/themes.rb @@ -157,7 +157,7 @@ def watch write_lockfile at_exit { remove_lockfile } - workflows.watch(current_dir, remote_theme) + workflows.watch(current_dir, remote_theme, local_theme) end end diff --git a/lib/bootic_cli/themes/workflows.rb b/lib/bootic_cli/themes/workflows.rb index ee5ef59..9026432 100644 --- a/lib/bootic_cli/themes/workflows.rb +++ b/lib/bootic_cli/themes/workflows.rb @@ -189,7 +189,7 @@ def publish(local_theme, remote_theme) end end - def watch(dir, remote_theme, watcher: Listen) + def watch(dir, remote_theme, local_theme, watcher: Listen) listener = watcher.to(dir) do |modified, added, removed| if modified.any? @@ -229,12 +229,31 @@ def watch(dir, remote_theme, watcher: Listen) } prompt.say "Preview changes at #{remote_theme.path} -- Hit Ctrl-C to stop watching for changes.", :cyan + + + if local_theme && File.exists?(File.join(dir, 'tailwind.config.js')) + source = local_theme.templates.find { |t| t.name['css'] && t.name['input'] } + target = local_theme.templates.find { |t| t.name['css'] && t.name['output'] } + + if source && target + notice "Tailwind config found! Firing the CLI in watch mode.." + run_tailwind_cli(source, target) # blocks + return + else + notice "Tailwind config found, but couldn't determine the source/input and target/output files..." + end + end + Kernel.sleep end private attr_reader :prompt + def run_tailwind_cli(source_css, target_css) + `npx tailwindcss -i #{source_css} -o #{target_css} --watch` + end + def check_dupes!(list) names = list.map { |f| f.file_name.downcase } dupes = names.group_by { |e| e }.select { |k, v| v.size > 1 }.map(&:first)