Sha256: 9bba821572356b091907a4521b31ef701cdba5a948a7c1e25a936029848b0178

Contents?: true

Size: 518 Bytes

Versions: 6

Compression:

Stored size: 518 Bytes

Contents

# ref. https://qiita.com/Tak-Iwamoto/items/efce14f67eb572d8742e
module Resizing::Rails::WebpackBundleHelper
  class BundleNotFound < StandardError; end

  def asset_bundle_path(file)
    valid_file?(file)
    return "/assets" + manifest.fetch(file)
  end

  private

  def manifest
    return @manifest ||= JSON.parse(File.read("app/javascript/dist/manifest.json"))
  end

  def valid_file?(entry)
    return true if manifest.key?(entry)
    raise BundleNotFound, "Could not find bundle with name #{entry}"
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
resizing-rails-0.4.1 app/helpers/resizing/rails/webpack_bundle_helper.rb
resizing-rails-0.4.0 app/helpers/resizing/rails/webpack_bundle_helper.rb
resizing-rails-0.3.0 app/helpers/resizing/rails/webpack_bundle_helper.rb
resizing-rails-0.2.0 app/helpers/resizing/rails/webpack_bundle_helper.rb
resizing-rails-0.1.0.pre2 app/helpers/resizing/rails/webpack_bundle_helper.rb
resizing-rails-0.1.0.pre app/helpers/resizing/rails/webpack_bundle_helper.rb