Sha256: d4f8ad244d94025c7ad918c5498006dfa42a9208d97a6b1405d95e2488431daa

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true
require 'rails'
require 'rails/railtie'
begin
  # Force assets:precompile to be defined before sewing_kit's railtie tries to
  # extend it.
  require "sprockets/railtie" if defined? Rails
# rubocop:disable Lint/HandleExceptions
rescue
  #
end
# rubocop:enable Lint/HandleExceptions
require 'sewing_kit/webpack/compiler'
require 'sewing_kit/webpack/helper'
require 'sewing_kit/webpack/dev'

module SewingKit
  class Railtie < ::Rails::Railtie
    initializer "sewing_kit.cache_production_manifest" do
      unless SewingKit::Railtie.development_server? || Rails.env.test?
        SewingKit::CachedProductionManifest = SewingKit::Webpack::Manifest::Base.load_metadata_from_node
      end
    end
    # rubocop:disable Metrics/BlockLength
    config.after_initialize do
      if SewingKit::Railtie.development_server?
        webpack_dev = SewingKit::Webpack::Dev.new
        webpack_dev.start
      end

      ActiveSupport.on_load(:action_view) do
        include SewingKit::Webpack::Helper
      end
    end
    rake_tasks do
      load "tasks/sewing_kit.rake"
    end

    def self.development_server?
      Rails.env.development? &&
        ENV['SK_SIMULATE_PRODUCTION'] != '1' &&
        (Rails.const_defined?(:Server) || ENV['SK_FORCE_DEV_SERVER'])
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sewing_kit-0.91.0 lib/sewing_kit/railtie.rb
sewing_kit-0.32.0.pre.beta.pre.4 lib/sewing_kit/railtie.rb
sewing_kit-0.32.0.pre.beta.pre.3 lib/sewing_kit/railtie.rb
sewing_kit-0.32.0.pre.beta.pre.1 lib/sewing_kit/railtie.rb
sewing_kit-0.31.2 lib/sewing_kit/railtie.rb