Module: Opal::Sprockets::MimeTypes

Included in:
Opal::Sprockets
Defined in:
lib/opal/sprockets/mime_types.rb

Instance Method Summary collapse

Instance Method Details

#mime_typesObject



6
7
8
# File 'lib/opal/sprockets/mime_types.rb', line 6

def mime_types
  @mime_types ||= []
end

#register_mime_type(mime_type) ⇒ Object



2
3
4
# File 'lib/opal/sprockets/mime_types.rb', line 2

def register_mime_type(mime_type)
  mime_types << mime_type
end

#sprockets_extnames_regexp(sprockets, opal_only: false) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/opal/sprockets/mime_types.rb', line 10

def sprockets_extnames_regexp(sprockets, opal_only: false)
  opal_extnames = sprockets.mime_types.map do |type, hash|
    hash[:extensions] if !opal_only || Opal::Sprockets.mime_types.include?(type)
  end.compact.flatten

  opal_extnames << ".js" unless opal_only

  Regexp.union(opal_extnames.map { |i| /#{Regexp.escape(i)}\z/ })
end