Sha256: 818dc42b8658dacb3a8fba235067457d9f2a4c9e9452df9bd9d941223e6d21e6

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

require 'rails'
require 'importmap-rails'
require 'cm_admin/version_manager'

module CmAdmin
  class Engine < Rails::Engine
    isolate_namespace CmAdmin

    initializer 'RailsAdmin precompile hook', group: :all do |app|
      app.config.assets.precompile += %w[
        cm_admin/cm_admin.css
        cm_admin/custom.js
        cm_admin/custom.css
      ]
    end

    def mount_path
      CmAdmin::Engine.routes.find_script_name({})
    end

    initializer 'cm_admin.importmap', before: 'importmap' do |app|
      # NOTE: this will add pins from this engine to the main app
      # https://github.com/rails/importmap-rails#composing-import-maps
      app.config.importmap.paths << root.join('config/importmap.rb')

      # NOTE: something about cache; I did not look into it.
      # https://github.com/rails/importmap-rails#sweeping-the-cache-in-development-and-test
      app.config.importmap.cache_sweepers << root.join('app/assets/javascripts')
    end

    # NOTE: add engine manifest to precompile assets in production
    initializer 'cm_admin.assets' do |app|
      app.config.assets.precompile += %w[cm_admin_manifest]
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cm-admin-4.4.8 lib/cm_admin/engine.rb
cm-admin-4.4.6 lib/cm_admin/engine.rb
cm-admin-4.4.1 lib/cm_admin/engine.rb
cm-admin-4.4.0 lib/cm_admin/engine.rb
cm-admin-4.3.0 lib/cm_admin/engine.rb
cm-admin-4.2.1 lib/cm_admin/engine.rb
cm-admin-4.2.0 lib/cm_admin/engine.rb
cm-admin-4.1.2 lib/cm_admin/engine.rb
cm-admin-4.1.1 lib/cm_admin/engine.rb
cm-admin-4.1.0 lib/cm_admin/engine.rb
cm-admin-4.0.0 lib/cm_admin/engine.rb