Sha256: 40ecd9c060d6d09d0df005c4d823f0e27e5982f4aa18edfb9ebb8b5c2e8d78fd

Contents?: true

Size: 800 Bytes

Versions: 3

Compression:

Stored size: 800 Bytes

Contents

# frozen_string_literal: true

module ::AmberComponent
  # Class which hooks into Rails
  # and configures the application.
  class Railtie < ::Rails::Railtie
    initializer 'amber_component.assets' do |app|
      app.config.assets.paths << (app.root / 'app' / 'components')
      app.config.assets.paths << (ROOT_GEM_PATH / 'assets' / 'javascripts')
      app.config.assets.precompile += %w[amber_component/stimulus_loading.js]

      next if ::Rails.env.production?

      components_root = app.root / 'app' / 'components'
      component_paths = ::Dir[components_root / '**' / '*.rb']
      app.config.eager_load_paths += component_paths

      ::ActiveSupport::Reloader.to_prepare do
        component_paths.each { |file| require_dependency(components_root / file) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
amber_component-1.2.0 lib/amber_component/railtie.rb
amber_component-1.1.1 lib/amber_component/railtie.rb
amber_component-1.1.0 lib/amber_component/railtie.rb