# 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.initialize_webpack" do is_development = Rails.env.development? && ENV['SK_SIMULATE_PRODUCTION'] != '1' if is_development && (Rails.const_defined?(:Server) || ENV['SK_FORCE_DEV_SERVER']) webpack_dev = SewingKit::Webpack::Dev.new webpack_dev.start end end config.after_initialize do ActiveSupport.on_load(:action_view) do include SewingKit::Webpack::Helper end end rake_tasks do load "tasks/sewing_kit.rake" end end end