Skip to content

Instantly share code, notes, and snippets.

@LBRapid
Created October 15, 2013 14:33
Show Gist options
  • Select an option

  • Save LBRapid/6992493 to your computer and use it in GitHub Desktop.

Select an option

Save LBRapid/6992493 to your computer and use it in GitHub Desktop.
Using sprockets outside of rails
require 'rubygems'
require 'sprockets'
task :default => [:release]
desc "Release the application"
task :release do
puts "Compiling JavaScript assets...hang tight!"
project_root = File.expand_path(File.dirname(__FILE__))
assets = Sprockets::Environment.new(project_root)
assets.append_path(File.join(project_root, 'javascripts'))
manifest = assets['manifest.js']
outpath = File.join(project_root, 'release')
outfile = Pathname.new(outpath).join('application.min.js')
FileUtils.mkdir_p outfile.dirname
manifest.write_to(outfile)
puts "Successfully compiled JavaScript assets!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment