Sha256: 222256d7493bc9e8998dedd8c72cef0a52b0357afffcd5526c07599061105813

Contents?: true

Size: 555 Bytes

Versions: 3

Compression:

Stored size: 555 Bytes

Contents

# frozen_string_literal: true

require 'frontman/app'

module AssetsHelper
  def asset_url(path)
    Frontman::App.instance.assets_manifest[path.sub(%r{^/}, '')] || path
  end

  def vendor_scripts_by_chunk(chunk, scripts)
    if chunk == 'vendors'
      raise ChunkNameError, '"vendors" is an invalid chunk name'
    end

    pattern = /.*~#{chunk}.*|.*#{chunk}~.*$/

    scripts.select { |file_name| pattern.match?(file_name) }.sort do |asset|
      asset.start_with?('vendors~') ? -1 : 1
    end
  end

  class ChunkNameError < ArgumentError
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
frontman-ssg-0.0.4 project-templates/webpack/helpers/assets_helper.rb
frontman-ssg-0.0.3 project-templates/webpack/helpers/assets_helper.rb
frontman-ssg-0.0.2 project-templates/webpack/helpers/assets_helper.rb