Module: SolidusAdmin::Tailwindcss Private

Defined in:
lib/solidus_admin/tailwindcss.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.compile_to_tempfile(erb_path, name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
47
48
49
50
51
# File 'lib/solidus_admin/tailwindcss.rb', line 44

def compile_to_tempfile(erb_path, name)
  Rails.root.join("tmp/solidus_admin/#{name}").tap do |file|
    content = ERB.new(File.read(erb_path)).result

    file.dirname.mkpath
    file.write(content)
  end
end

.config_app_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/solidus_admin/tailwindcss.rb', line 28

def config_app_path
  Rails.root.join("config/solidus_admin/tailwind.config.js.erb")
end

.config_engine_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
# File 'lib/solidus_admin/tailwindcss.rb', line 32

def config_engine_path
  SolidusAdmin::Engine.root.join("config/solidus_admin/tailwind.config.js.erb")
end

.copy_file(src, dst) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
56
# File 'lib/solidus_admin/tailwindcss.rb', line 53

def copy_file(src, dst)
  FileUtils.mkdir_p(File.dirname(dst))
  FileUtils.cp(src, dst)
end

.run(args = "") ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/solidus_admin/tailwindcss.rb', line 11

def run(args = "")
  config_file_path = compile_to_tempfile(
    [config_app_path, config_engine_path].find(&:exist?),
    "tailwind.config.js"
  )
  stylesheet_file_path = compile_to_tempfile(
    [stylesheet_app_path, stylesheet_engine_path].find(&:exist?),
    "application.tailwind.css"
  )

  system "#{::Tailwindcss::Engine.root.join('exe/tailwindcss')} \
     -i #{stylesheet_file_path} \
     -o #{Rails.root.join('app/assets/builds/solidus_admin/tailwind.css')} \
     -c #{config_file_path} \
     #{args}"
end

.stylesheet_app_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/solidus_admin/tailwindcss.rb', line 36

def stylesheet_app_path
  Rails.root.join("app/assets/stylesheets/solidus_admin/application.tailwind.css.erb")
end

.stylesheet_engine_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/solidus_admin/tailwindcss.rb', line 40

def stylesheet_engine_path
  SolidusAdmin::Engine.root.join("app/assets/stylesheets/solidus_admin/application.tailwind.css.erb")
end