Created
December 4, 2012 03:18
-
-
Save jrmoran/4200226 to your computer and use it in GitHub Desktop.
Sprockets 2.8.1 Precompile CoffeeScript for non rack apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :js do | |
require 'sprockets' | |
environment = Sprockets::Environment.new(File.dirname(__FILE__)) | |
environment.append_path 'src/bower' | |
environment.append_path 'src/coffee' | |
source_code = environment['app.coffee'] | |
desc 'compile CoffeeScript with Sprockets' | |
task :compile do | |
bundle_file = './build/js/app.bundle.js' | |
File.open(bundle_file, 'w'){ |f| f.write(source_code) } | |
puts "app.coffee -> #{bundle_file}" | |
end | |
desc 'compile and minify CoffeeScript with Sprockets' | |
task :min do | |
require 'uglifier' | |
bundle_min = './dist/js/app.bundle.min.js' | |
source_min = Uglifier.compile(source_code) | |
File.open(bundle_min, 'w'){ |f| f.write(source_min) } | |
puts "app.coffee -> #{bundle_min}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment