Sha256: f45ebdbed473583ea1b87446aa2f230fbc0d23f746948863412bdd59a902395a

Contents?: true

Size: 1.74 KB

Versions: 6

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

require "dassets"
require "dassets/server"
require "dassets-erubi"
require "dassets-sass"

module MuchRails
  Assets = Dassets
end

module MuchRails::Assets
  def self.configure_for_rails(rails)
    MuchRails::Assets.configure do |config|
      # Cache fingerprints in memory for performance gains.
      config.fingerprint_cache MuchRails::Assets::MemCache.new

      # Cache compiled content in memory in development/test for performance
      # gains since we aren't caching to the file system. Otherwise, don't
      # cache in memory as we are caching to the file system and won't benefit
      # from the in memory cache.
      much_rails_content_cache =
        if rails.env.development? || rails.env.test?
          MuchRails::Assets::MemCache.new
        else
          MuchRails::Assets::NoCache.new
        end
      config.content_cache much_rails_content_cache

      # Cache out compiled file content to the public folder in non
      # development/test environments.
      if !rails.env.development? && !rails.env.test?
        config.file_store rails.root.join("public")
      end

      # Look for asset files in the app/assets folder. Support ERB processing
      # on all .js and .scss files. Support compilation of .scss files.
      config.source rails.root.join("app", "assets") do |s|
        # Reject SCSS partials
        s.filter do |paths|
          paths.reject{ |p| File.basename(p) =~ /^_.*\.scss$/ }
        end

        s.engine "js",   MuchRails::Assets::Erubi::Engine
        s.engine "scss", MuchRails::Assets::Erubi::Engine
        s.engine "scss", MuchRails::Assets::Sass::Engine, {
          syntax: "scss",
          output_style: "compressed",
        }
      end
    end
    MuchRails::Assets.init
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
much-rails-0.2.1 lib/much-rails/assets.rb
much-rails-0.2.0 lib/much-rails/assets.rb
much-rails-0.1.3 lib/much-rails/assets.rb
much-rails-0.1.2 lib/much-rails/assets.rb
much-rails-0.1.1 lib/much-rails/assets.rb
much-rails-0.1.0 lib/much-rails/assets.rb