Skip to content

Instantly share code, notes, and snippets.

@pk
Created November 9, 2011 15:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pk/1351769 to your computer and use it in GitHub Desktop.
Save pk/1351769 to your computer and use it in GitHub Desktop.
Nanoc Juicer filter for minifying CSS/JS
module PK
module Filter
class Juice < Nanoc3::Filter
identifier :juice
type :text
def run(content, params={})
input_filename = File.join('content', @item.path)
output_filename = File.absolute_path(File.join('tmp', "#{@item.path}"))
system('juicer', 'merge', '--force', '-o', output_filename, input_filename)
minified = File.open(output_filename, 'r') { |f| f.read }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment