Sha256: 9ea076467780795f4c0fd967539ce944771f4a98a73d062a708910d62884e5a4

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'pageflow/rails_version'

module PageflowPaged
  # Rails integration
  class Engine < ::Rails::Engine
    isolate_namespace PageflowPaged

    if Pageflow::RailsVersion.experimental?
      lib = root.join('lib')

      config.autoload_paths << lib
      config.eager_load_paths << lib

      initializer 'pageflow_paged.autoloading' do
        Rails.autoloaders.main.ignore(
          lib.join('tasks')
        )
      end
    else
      config.paths.add('lib', eager_load: true)
    end

    config.i18n.load_path += Dir[config.root.join('config', 'locales', '**', '*.yml').to_s]

    initializer 'pageflow_paged.assets.precompile' do |app|
      # Pageflow Paged requires an older version of React than the one
      # that comes bundled with react-rails. The React builds from the
      # originally used version of react-rails have been copied to
      # paged/vendor/assets/javascripts/<env>/pageflow_paged/vendor.
      #
      # Replicate the react-rails setup to use different React builds
      # based on the Rails environment.
      variant = Rails.env.production? ? 'production' : 'development'
      app.config.assets.paths << config.root.join('vendor', 'assets', 'javascripts', variant).to_s

      app.config.assets.precompile += %w[
        pageflow_paged/vendor.js
        pageflow_paged/editor.js
        pageflow_paged/frontend.js
        pageflow_paged/server_rendering.js
        pageflow_paged/editor.css
      ]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pageflow-16.1.0 entry_types/paged/lib/pageflow_paged/engine.rb