Module: Tailwindcss::Commands

Defined in:
lib/tailwindcss/commands.rb

Class Method Summary collapse

Class Method Details

.compile_command(debug: false, **kwargs) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/tailwindcss/commands.rb', line 6

def compile_command(debug: false, **kwargs)
  command = [
    Tailwindcss::Ruby.executable(**kwargs),
    "-i", Rails.root.join("app/assets/stylesheets/application.tailwind.css").to_s,
    "-o", Rails.root.join("app/assets/builds/tailwind.css").to_s,
    "-c", Rails.root.join("config/tailwind.config.js").to_s,
  ]

  command << "--minify" unless (debug || rails_css_compressor?)

  postcss_path = Rails.root.join("config/postcss.config.js")
  command += ["--postcss", postcss_path.to_s] if File.exist?(postcss_path)

  command
end

.rails_css_compressor?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/tailwindcss/commands.rb', line 30

def rails_css_compressor?
  defined?(Rails) && Rails&.application&.config&.assets&.css_compressor.present?
end

.watch_command(always: false, poll: false, **kwargs) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/tailwindcss/commands.rb', line 22

def watch_command(always: false, poll: false, **kwargs)
  compile_command(**kwargs).tap do |command|
    command << "-w"
    command << "always" if always
    command << "-p" if poll
  end
end