Sha256: b79f418023f9dc0d3488a15938afb58ff6b15007a8d1ea70e7c5ce28018062ed

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require "rails/engine"
require "action_cable/engine"
require "view_component"
require "turbo-rails"

module Coco
  class Engine < ::Rails::Engine
    isolate_namespace Coco

    COLLAPSE_DIRS = %w[shared]

    config.autoload_paths += %W[
      #{root}/app/components
      #{root}/app/helpers
    ]

    initializer "coco.autoloading" do |app|
      coco_dir = "#{root}/app/components/coco"

      app.autoloaders.each do |autoloader|
        COLLAPSE_DIRS.each do |path|
          autoloader.collapse("#{coco_dir}/#{path}")
        end

        Dir.glob("#{coco_dir}/shared/**/*.rb").each do |path|
          autoloader.collapse(File.dirname(path))
        end

        Dir.glob("#{coco_dir}/{app,book}/{blocks,elements,layouts}/**/*.rb").each do |path|
          autoloader.collapse(File.dirname(path))
        end
      end

      if Rails.env.production?
        Rails.application.config.to_prepare do
          Rails.autoloaders.main.eager_load_dir(coco_dir)
        end
      end
    end

    initializer "coco.assets" do |app|
      if app.config.respond_to?(:assets)
        app.config.assets.precompile += %w[coco/manifest.js *.svg]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coveragebook_components-0.12.2 lib/coco/engine.rb
coveragebook_components-0.12.1 lib/coco/engine.rb
coveragebook_components-0.12.0 lib/coco/engine.rb