Module: Frontrunner::Helper

Defined in:
lib/frontrunner/helper.rb

Instance Method Summary collapse

Instance Method Details

#webpack_include_tag(*sources) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/frontrunner/helper.rb', line 3

def webpack_include_tag(*sources)
  options = sources.extract_options!
  sources =
    sources.map do |source|
      @webpack_manifest = nil if Rails.env.development?
      entry = webpack_manifest[source]
      raise Frontrunner::Error, "Could not find webpack entry point: #{source}" unless entry
      entry["js"]
    end
  javascript_include_tag *sources, options
end

#webpack_manifestObject



15
16
17
18
19
# File 'lib/frontrunner/helper.rb', line 15

def webpack_manifest
  @webpack_manifest ||= JSON.parse(File.read(Rails.root.join("webpack-assets.json")))
rescue => e
  raise Frontrunner::Error, "Error reading webpack manifest - be sure to start the dev server"
end