Class: Sprockets::Vue::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets/vue/style.rb

Constant Summary collapse

STYLE_REGEX =
Utils.node_regex('style')
STYLE_COMPILES =
{
  'scss' => Sprockets::ScssProcessor,
  'sass' => Sprockets::SassProcessor,
  nil => ->(i){i[:data]}
}

Class Method Summary collapse

Class Method Details

.cache_keyObject



23
24
25
26
27
28
# File 'lib/sprockets/vue/style.rb', line 23

def cache_key
  [
    self.name,
    VERSION,
  ].freeze
end

.call(input) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sprockets/vue/style.rb', line 10

def call(input)
  data = input[:data]
  input[:cache].fetch([cache_key, input[:filename], data]) do
    style = STYLE_REGEX.match(data)
    if style
      input[:data] = style[:content]
      STYLE_COMPILES[style[:lang]].call(input)
    else
      ''
    end
  end
end