Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bootic_cli/commands/themes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 20 additions & 1 deletion lib/bootic_cli/themes/workflows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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)
Expand Down