Sha256: 667bbb601cf3eeeeec06bc78283b3b4287bf8fc546b513aa7c9d0050e63bee1e

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true
module ActiveAdmin
  class Engine < ::Rails::Engine
    isolate_namespace ActiveAdmin

    # Set default values for app_path and load_paths before running initializers
    initializer "active_admin.load_app_path", before: :load_config_initializers do |app|
      ActiveAdmin::Application.setting :app_path, app.root
      ActiveAdmin::Application.setting :load_paths, [File.expand_path("app/admin", app.root)]
    end

    initializer "active_admin.precompile", group: :all do |app|
      if app.config.respond_to?(:assets)
        app.config.assets.precompile += %w(active_admin.js active_admin.css active_admin_manifest.js)
      end
    end

    initializer "active_admin.importmap", after: "importmap" do |app|
      # Skip if importmap-rails is not installed
      next unless app.config.respond_to?(:importmap)

      ActiveAdmin.importmap.draw(Engine.root.join("config", "importmap.rb"))
      package_path = Engine.root.join("app/javascript")
      if app.config.respond_to?(:assets)
        app.config.assets.paths << package_path
        app.config.assets.paths << Engine.root.join("vendor/javascript")
      end

      if app.config.importmap.sweep_cache
        ActiveAdmin.importmap.cache_sweeper(watches: package_path)
        ActiveSupport.on_load(:action_controller_base) do
          before_action { ActiveAdmin.importmap.cache_sweeper.execute_if_updated }
        end
      end
    end

    initializer "active_admin.routes" do
      require_relative "helpers/routes/url_helpers"
    end

    initializer "active_admin.deprecator" do |app|
      app.deprecators[:activeadmin] = ActiveAdmin.deprecator if app.respond_to?(:deprecators)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activeadmin-4.0.0.beta15 lib/active_admin/engine.rb
activeadmin-4.0.0.beta14 lib/active_admin/engine.rb
activeadmin-4.0.0.beta13 lib/active_admin/engine.rb