Module: Tailwindcss::Commands
- Defined in:
- lib/tailwindcss/commands.rb
Defined Under Namespace
Classes: ExecutableNotFoundException, UnsupportedPlatformException
Class Method Summary
collapse
Class Method Details
.compile_command(debug: false, **kwargs) ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/tailwindcss/commands.rb', line 58
def compile_command(debug: false, **kwargs)
[
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.cjs").to_s,
].tap do |command|
command << "--minify" unless (debug || rails_css_compressor?)
end
end
|
.executable(exe_path: File.expand_path(File.join(__dir__, "..", "..", "exe"))) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/tailwindcss/commands.rb', line 18
def executable(
exe_path: File.expand_path(File.join(__dir__, "..", "..", "exe"))
)
if Tailwindcss::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match(Gem::Platform.new(p)) }
raise UnsupportedPlatformException, <<~MESSAGE
tailwindcss-rails-cjs does not support the #{platform} platform
Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation
MESSAGE
end
exe_path = Dir.glob(File.expand_path(File.join(exe_path, "*", "tailwindcss"))).find do |f|
Gem::Platform.match(Gem::Platform.new(File.basename(File.dirname(f))))
end
if exe_path.nil?
raise ExecutableNotFoundException, <<~MESSAGE
Cannot find the tailwindcss executable for #{platform} in #{exe_path}
If you're using bundler, please make sure you're on the latest bundler version:
gem install bundler
bundle update --bundler
Then make sure your lock file includes this platform by running:
bundle lock --add-platform #{platform}
bundle install
See `bundle lock --help` output for details.
If you're still seeing this message after taking those steps, try running
`bundle config` and ensure `force_ruby_platform` isn't set to `true`. See
https://github.com/rails/tailwindcss-rails-cjs#check-bundle_force_ruby_platform
for more details.
MESSAGE
end
exe_path
end
|
14
15
16
|
# File 'lib/tailwindcss/commands.rb', line 14
def platform
[:cpu, :os].map { |m| Gem::Platform.local.send(m) }.join("-")
end
|
.rails_css_compressor? ⇒ Boolean
76
77
78
|
# File 'lib/tailwindcss/commands.rb', line 76
def rails_css_compressor?
defined?(Rails) && Rails&.application&.config&.assets&.css_compressor.present?
end
|
.watch_command(poll: false, **kwargs) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/tailwindcss/commands.rb', line 69
def watch_command(poll: false, **kwargs)
compile_command(**kwargs).tap do |command|
command << "-w"
command << "-p" if poll
end
end
|