Sha256: 98585bcd50d052066bbc1434d82c2649f66f7fb3107a16787ff0a89b12dfc775

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

Jets::Application.send(:attr_accessor, :importmap)

module ImportmapJets
  # class Turbine < ::Jets::Turbine
  class Engine < ::Jets::Engine
    config.importmap = ActiveSupport::OrderedOptions.new
    config.importmap.paths = []
    config.importmap.sweep_cache = Jets.env.development? || Jets.env.test?
    config.importmap.cache_sweepers = []
    config.importmap.rescuable_asset_errors = []

    config.autoload_once_paths = %W( #{root}/app/helpers )

    initializer "importmap" do |app|
      app.importmap = Importmap::Map.new
      config.importmap.paths << app.root.join("config/importmap.rb")
      config.importmap.paths.each { |path| app.importmap.draw(path) }
    end

    initializer "importmap.reloader" do |app|
      app.reloaders << ImportmapJets::Reloader.new(app)
    end

    initializer "importmap.assets" do |app|
      if app.config.respond_to?(:assets) && app.config.assets.paths.present?
        app.config.assets.paths << Jets.root.join("app/javascript")
        app.config.assets.paths << Jets.root.join("vendor/javascript")

        # app/assets/javascripts/es-module-shims.js
        app.config.assets.precompile += %w( es-module-shims.js es-module-shims.min.js es-module-shims.js.map )
        javascripts = paths['app/assets'].absolute_current + "/javascripts"
        app.config.assets.paths << javascripts
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
importmap-jets-0.1.1 lib/importmap_jets/engine.rb
importmap-jets-0.1.0 lib/importmap_jets/engine.rb