Sha256: 496055b86aea940e68c0e781fa1c959a88e1219e9cb2bba134a743431d1846df

Contents?: true

Size: 1.57 KB

Versions: 26

Compression:

Stored size: 1.57 KB

Contents

require "rails/railtie"

require "webpacker/helper"
require "webpacker/dev_server_proxy"

class Webpacker::Engine < ::Rails::Engine
  # Allows Webpacker config values to be set via Rails env config files
  config.webpacker = ActiveSupport::OrderedOptions.new

  initializer "webpacker.proxy" do |app|
    insert_middleware = Webpacker.config.dev_server.present? rescue nil
    if insert_middleware
      app.middleware.insert_before 0,
        Rails::VERSION::MAJOR >= 5 ?
          Webpacker::DevServerProxy : "Webpacker::DevServerProxy", ssl_verify_none: true
    end
  end

  initializer "webpacker.helper" do
    ActiveSupport.on_load :action_controller do
      ActionController::Base.helper Webpacker::Helper
    end

    ActiveSupport.on_load :action_view do
      include Webpacker::Helper
    end
  end

  initializer "webpacker.logger" do
    config.after_initialize do
      if ::Rails.logger.respond_to?(:tagged)
        Webpacker.logger = ::Rails.logger
      else
        Webpacker.logger = ActiveSupport::TaggedLogging.new(::Rails.logger)
      end
    end
  end

  initializer "webpacker.bootstrap" do
    if defined?(Rails::Server) || defined?(Rails::Console)
      Webpacker.bootstrap
      if defined?(Spring)
        require "spring/watcher"
        Spring.after_fork { Webpacker.bootstrap }
        Spring.watch(Webpacker.config.config_path)
      end
    end
  end

  initializer "webpacker.set_source" do |app|
    if Webpacker.config.config_path.exist?
      app.config.javascript_path = Webpacker.config.source_path.relative_path_from(Rails.root.join("app")).to_s
    end
  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/lib/webpacker/railtie.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/lib/webpacker/railtie.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/lib/webpacker/railtie.rb
jetpacker-0.7.0 lib/webpacker/railtie.rb
webpacker-5.4.4 lib/webpacker/railtie.rb
jetpacker-0.6.0 lib/webpacker/railtie.rb
webpacker-5.4.3 lib/webpacker/railtie.rb
webpacker-5.4.2 lib/webpacker/railtie.rb
webpacker-5.4.1 lib/webpacker/railtie.rb
webpacker-5.4.0 lib/webpacker/railtie.rb
webpacker-5.3.0 lib/webpacker/railtie.rb
webpacker-5.2.2 lib/webpacker/railtie.rb
webpacker-6.0.0.beta.7 lib/webpacker/railtie.rb
webpacker-6.0.0.beta.6 lib/webpacker/railtie.rb
webpacker-6.0.0.beta.5 lib/webpacker/railtie.rb
webpacker-6.0.0.beta.4 lib/webpacker/railtie.rb
webpacker-6.0.0.beta.3 lib/webpacker/railtie.rb
jetpacker-0.5.0 lib/webpacker/railtie.rb
webpacker-6.0.0.beta.2 lib/webpacker/railtie.rb
webpacker-6.0.0.beta.1 lib/webpacker/railtie.rb