Created
August 22, 2011 06:56
-
-
Save anthonyshort/1161821 to your computer and use it in GitHub Desktop.
Cakefile: Simple Combiner + Uglifier - Based on https://github.com/rwldrn/idiomatic.js
This file contains hidden or 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
| FILES = | |
| libraries: [ | |
| "libs/jquery/jquery.ui.widget.js", | |
| "libs/jquery/jquery.nsm.container.js", | |
| "libs/jquery/jquery.nsmToc.js", | |
| "libs/jquery/jquery.nsm.BigTarget.js", | |
| "libs/jquery/nsm-sectionComments/jquery-nsm-sectionComments.js", | |
| "libs/jquery/jquery.placeholder.js", | |
| "libs/jquery/jquery.pjax.js", | |
| "libs/mediaplayer-5.7/jwplayer.js", | |
| "libs/shadowbox/shadowbox.js", | |
| "libs/jquery/jquery.cycle.js" | |
| ], | |
| script: [ | |
| "behaviours.js", | |
| "favourites.js", | |
| "navigation.js", | |
| "pjax.js", | |
| "purchase.js", | |
| "section-comments.js", | |
| "select-state.js", | |
| "validation.js" | |
| ], | |
| homepage: [ | |
| "homepage-video.js", | |
| "homepage-cycle.js", | |
| "homepage-promos.js" | |
| ] | |
| # //////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| # DONT TOUCH ANYTHING BELOW HERE | |
| # //////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| fs = require "fs" | |
| sys = require "sys" | |
| uglify = require "uglify-js" | |
| print = require("sys").print | |
| util = require "util" | |
| exec = require("child_process").exec | |
| spawn = require("child_process").spawn | |
| LICENSE = "/*! Copyright 2011 Newism (http://newism.com.au) " + new Date() + " */" | |
| DIST = "./" | |
| task "compress", 'Uglify JS', (params)-> | |
| print "\n Compressing...\n\n" | |
| files = FILES | |
| all = "" | |
| for own type of files | |
| for file in files[type] | |
| if file.match(/^.*js$/) and file | |
| print " " + file + "\n" | |
| all += (fs.readFileSync file).toString() | |
| ast = uglify.parser.parse all | |
| out = fs.openSync DIST + type + ".min.js", "w+" | |
| ast = uglify.uglify.ast_mangle ast | |
| ast = uglify.uglify.ast_squeeze ast | |
| fs.writeSync out, LICENSE + "\n" + uglify.uglify.gen_code(ast) | |
| print "\n Complete! " + DIST + type + ".min.js \n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment