Created
April 6, 2012 16:36
-
-
Save Zenithar/2321191 to your computer and use it in GitHub Desktop.
CoffeeScript command line extension : comments and output minification
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
# Quoted in http://ww.zenithar.org/2012/04/06/iced-coffeescript-minification/ | |
# Based on https://github.com/jashkenas/coffee-script/wiki/%5BExtensibility%5D-Hooking-into-the-Command-Line-Compiler | |
# | |
# Don't forget to install UglifyJS | |
# npm install -g uglify-js | |
# | |
# CoffeeScript = require 'coffee-script' | |
CoffeeScript = require 'iced-coffee-script' | |
{parser, uglify} = require 'uglify-js' | |
CoffeeScript.on 'success', (task) -> | |
ast = parser.parse task.output | |
code = uglify.gen_code uglify.ast_squeeze uglify.ast_mangle ast, extra: yes | |
task.output = """ | |
/** | |
* My Fancy minified javascript file | |
* Blah blah blah | |
* Copyright (c) #{ new Date().getFullYear() } Thibault NORMAND | |
**/\n | |
""" + code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment