Module: RubyCms::CssCompiler

Defined in:
lib/ruby_cms/css_compiler.rb

Overview

Compiles admin.css from component files (no Rails required). Used by Engine.compile_admin_css and rake tasks.

Constant Summary collapse

COMPONENTS =

Core shared styles MUST be loaded first, then specific components

%w[
  shared
  layout sidebar header cards dashboard buttons forms alerts
  flash_toast modals content_blocks visitor_errors settings
  bulk_action_table bulk_action_table_bar bulk_action_table_delete
  visual_editor visual_editor_header visual_editor_preview visual_editor_modal
  visual_editor_edit_mode analytics
  mobile scrollbar utilities
].freeze

Class Method Summary collapse

Class Method Details

.compile(gem_root, dest_path) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ruby_cms/css_compiler.rb', line 20

def self.compile(gem_root, dest_path)
  src_dir = Pathname(gem_root).join("app/assets/stylesheets/ruby_cms")
  components_dir = src_dir.join("components")
  header = <<~CSS

  CSS
  content = COMPONENTS.filter_map do |name|
    file = components_dir.join("#{name}.css")
    next nil unless file.exist?

    "/* ===== Component: #{name} ===== */\n#{File.read(file)}\n"
  end.compact.join("\n")
  File.write(dest_path, header + content)
end