Sha256: fd9aeaa88a4e0e88048e294c66a98cf083631ad2eb808fb23719d0f1865630df

Contents?: true

Size: 1.21 KB

Versions: 22

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require "yaml"

begin
  module AutoprefixedRails
    class Railtie < ::Rails::Railtie # :nodoc:
      rake_tasks do |app|
        require "rake/autoprefixer_tasks"
        Rake::AutoprefixerTasks.new(config) if defined? app.assets
      end

      if config.respond_to?(:assets) && !config.assets.nil?
        config.assets.configure do |env|
          AutoprefixerRails.install(env, config)
        end
      else
        initializer :setup_autoprefixer, group: :all do |app|
          AutoprefixerRails.install(app.assets, config) if defined?(app.assets) && !app.assets.nil?
        end
      end

      # Read browsers requirements from application or engine config
      def config
        params = {}

        roots.each do |root|
          file = File.join(root, "config/autoprefixer.yml")

          next unless File.exist?(file)

          parsed = ::YAML.load_file(file)
          next unless parsed

          params = parsed

          break
        end

        params = params.symbolize_keys
        params[:env] ||= Rails.env.to_s
        params
      end

      def roots
        [Rails.application.root] + Rails::Engine.subclasses.map(&:root)
      end
    end
  end
rescue LoadError
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
autoprefixer-rails-10.4.0.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.3.3.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.3.1.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.2.5.1 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.2.5.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.2.4.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.2.0.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.1.0.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.0.3.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.0.2.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.0.1.3 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.0.1.2 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.0.1.1 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.0.1.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.0.0.2 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.0.0.1 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-10.0.0 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-9.8.6.5 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-9.8.6.4 lib/autoprefixer-rails/railtie.rb
autoprefixer-rails-9.8.6.3 lib/autoprefixer-rails/railtie.rb