Sha256: 12e686fcdebb5bd8ee3f5beebe2dacb82f5a320063c3bfbfb32df5d7232dd69e

Contents?: true

Size: 1.41 KB

Versions: 28

Compression:

Stored size: 1.41 KB

Contents

namespace :spree do
  namespace :dev do
    desc "Compile non-partial less stylesheets into public/stylesheets for the last loaded theme extension."
    task :less => :environment do
      require 'less'

      #RAILS 3 TODO - figure out final resting place for less
      #$LESS_LOAD_PATH = Spree::ExtensionLoader.stylesheet_source_paths.reverse
      $LESS_LOAD_PATH = [Rails.root.join("core", "app", "stylesheets")]

      # css files are written to the last loaded theme extension's public/stylesheets directory
      output_path = $LESS_LOAD_PATH.first.to_s.gsub("app/stylesheets", "public/stylesheets")
      FileUtils.mkpath(output_path)

      # Build a list of all unique non-partial .less files to compile
      stylesheets = $LESS_LOAD_PATH.map do |path|
        Dir[  File.join(path,"[^_]*.less").to_s].map! {|f| File.basename(f) }
      end.flatten.uniq

      stylesheets.each do |less_filename|
        css_filename = less_filename.gsub(/.less/, '.css')
        paths = $LESS_LOAD_PATH.map { |p| File.join(p, less_filename) }
        if path = paths.detect {|p| File.exists?(p)}
          puts "Compiling #{less_filename} from path: #{path}"
          destination = File.join(output_path, css_filename)
          f = File.new(destination, File::CREAT|File::TRUNC|File::RDWR, 0644)
          f.write Less::Engine.new(File.new(path)).to_css
          puts "  written to #{destination}"
        end
      end

    end
  end
end

Version data entries

28 entries across 28 versions & 6 rubygems

Version Path
apispree_core-0.0.0 lib/tasks/themes.rake
My-Commerce_core-1.1.0 lib/tasks/themes.rake
My-Commerce_core-1.0.0 lib/tasks/themes.rake
MyCommerceapi-1.0.0 core/lib/tasks/themes.rake
MyCommerce-0.0.3 core/lib/tasks/themes.rake
rfcommerce_core-0.0.3 lib/tasks/themes.rake
spree_core-0.60.6 lib/tasks/themes.rake
spree_core-0.60.5 lib/tasks/themes.rake
spree_core-0.30.2 lib/tasks/themes.rake
spree_core-0.40.4 lib/tasks/themes.rake
spree_core-0.50.4 lib/tasks/themes.rake
spree_core-0.60.4 lib/tasks/themes.rake
spree_core-0.50.3 lib/tasks/themes.rake
spree_core-0.60.3 lib/tasks/themes.rake
spree_core-0.60.2 lib/tasks/themes.rake
spree_core-0.60.1 lib/tasks/themes.rake
spree_core-0.60.0 lib/tasks/themes.rake
spree_core-0.60.0.RC1 lib/tasks/themes.rake
spree_core-0.50.2 lib/tasks/themes.rake
spree_core-0.50.1 lib/tasks/themes.rake