module JsAssets
  class List
    @exclude = ['application.js']
    @allow = ['.eof']
    def self.fetch
      project_assets ={}
      ::Rails.application.assets.each_logical_path(::Rails.application.config.assets.precompile) do |lp|
        puts lp
        next if matches_filter(@exclude, lp)
        next unless matches_filter(@allow, lp)
        project_assets[lp] = ::ApplicationController.helpers.asset_path(lp)
      end
      return project_assets
    end

  protected

    # from 
    # https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/base.rb:418
    def matches_filter(filters, logical_path, filename)
      return true if filters.empty?

      filters.any? do |filter|
        if filter.is_a?(Regexp)
          filter.match(logical_path)
        elsif filter.respond_to?(:call)
          if filter.arity == 1
            filter.call(logical_path)
          else
            filter.call(logical_path, filename.to_s)
          end
        else
          File.fnmatch(filter.to_s, logical_path)
        end
      end
    end
  end
end

module JsAssets
  class List
    class << self
      attr_accessor :exclude, :allow
    end
    @exclude = ['application.js']
    @allow = ['*.html']
    def self.fetch
      project_assets = {}
      assets_filters = ::Rails.application.config.assets.precompile
      ::Rails.application.assets.each_file do |filename|
        if logical_path = ::Rails.application.assets.send(:logical_path_for_filename, filename, assets_filters)
          next if matches_filter(@exclude, logical_path, filename)
          next unless matches_filter(@allow, logical_path, filename)
          project_assets[logical_path] = ::ApplicationController.helpers.asset_path(logical_path)
        end
      end
      return project_assets
    end

  protected
    # from 
    # https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/base.rb:418
    def self.matches_filter(filters, logical_path, filename)
      return true if filters.empty?

      filters.any? do |filter|
        if filter.is_a?(Regexp)
          filter.match(logical_path)
        elsif filter.respond_to?(:call)
          if filter.arity == 1
            filter.call(logical_path)
          else
            filter.call(logical_path, filename.to_s)
          end
        else
          # puts filter
          File.fnmatch(filter.to_s, logical_path)
        end
      end
    end
  end
end

Add configurable variables for filter
Add configurable variables for filter
