Class: WebpackRails::Processor

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/webpack_rails/processor.rb

Instance Method Summary collapse

Instance Method Details

#evaluate(context, locals) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/webpack_rails/processor.rb', line 11

def evaluate(context, locals)
  return data unless context.pathname.to_s.include?('.bundle')

  # wait til webpack is done before loading
  result = WebpackRails::Task.run_webpack

  result[:modules].map{|m| context.depend_on m}

  bundle_contents = context.pathname.open.read
  # rewrite $asset_paths in strings
  bundle_contents.gsub(/['"]\$asset_path\/([^'"]+?)['"]/) {|s| "'#{context.asset_path($1)}'" }
end

#prepareObject



8
9
# File 'lib/webpack_rails/processor.rb', line 8

def prepare
end