Class: Middleman::Tailwind::Main
- Inherits:
-
Extension
- Object
- Extension
- Middleman::Tailwind::Main
- Defined in:
- lib/middleman/tailwind.rb
Instance Method Summary collapse
- #application_css ⇒ Object
- #config_file ⇒ Object
- #destination ⇒ Object
- #executable ⇒ Object
-
#initialize(app, options_hash = {}, &block) ⇒ Main
constructor
A new instance of Main.
- #platform ⇒ Object
- #ready ⇒ Object
Constructor Details
#initialize(app, options_hash = {}, &block) ⇒ Main
Returns a new instance of Main.
14 15 16 17 18 19 20 21 22 |
# File 'lib/middleman/tailwind.rb', line 14 def initialize(app, = {}, &block) super @gem_dir = File. "../..", __dir__ @project_dir = Dir.pwd @config_path = .config_path @css_path = .css_path @destination_path = .destination_path end |
Instance Method Details
#application_css ⇒ Object
32 33 34 35 36 |
# File 'lib/middleman/tailwind.rb', line 32 def application_css return File.join(@project_dir, @css_path) if @css_path File.join(@gem_dir, "tailwind/application.tailwind.css") end |
#config_file ⇒ Object
42 43 44 45 46 |
# File 'lib/middleman/tailwind.rb', line 42 def config_file return File.join(@project_dir, @config_path) if @config_path File.join(@gem_dir, "tailwind/tailwind.config.js") end |
#destination ⇒ Object
38 39 40 |
# File 'lib/middleman/tailwind.rb', line 38 def destination File.join(@project_dir, @destination_path) end |
#executable ⇒ Object
28 29 30 |
# File 'lib/middleman/tailwind.rb', line 28 def executable Upstream::NATIVE_PLATFORMS[platform] end |
#platform ⇒ Object
24 25 26 |
# File 'lib/middleman/tailwind.rb', line 24 def platform %i[cpu os].map { |m| Gem::Platform.local.send(m) }.join("-") end |
#ready ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/middleman/tailwind.rb', line 48 def ready exe = File.join(@gem_dir, "exe/#{executable}") cmd = "#{exe} -c #{config_file} -i #{application_css} -o #{destination}" if app.mode?(:server) Thread.new do system("#{cmd} -w", out: $stdout) end else puts "Building Tailwind CSS..." system(cmd, out: $stdout) end end |