Class: ViewComponentScopedCss::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/view_component_scoped_css/loader.rb

Overview

Resolve css module naming after loading and compiling scss files to provide final css

Instance Method Summary collapse

Constructor Details

#initialize(view_component_class) ⇒ Loader

class_attribute :compile_options, default: { source_map: true, style: { output: :compressed } }



10
11
12
13
# File 'lib/view_component_scoped_css/loader.rb', line 10

def initialize(view_component_class)
  @identifier = view_component_class.name.sub("::Component", "").underscore.split("/").join('\:\:')
  @path = "app/components#{view_component_class.virtual_path}.scss"
end

Instance Method Details

#callObject



15
16
17
18
19
# File 'lib/view_component_scoped_css/loader.rb', line 15

def call
  ViewComponentScopedCss::Compiler.new(path: @path, identifier: @identifier).call
rescue Sass::CompileError => e
  raise "scss[#{@path}] #{e.message}"
end