Created
May 15, 2011 17:05
-
-
Save mrjjwright/973311 to your computer and use it in GitHub Desktop.
Cake file that packages files from npm or locally. Looks in local node_modules for npm packages.
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
| exports.js_local = 'frontend/js/libs' | |
| exports.js = | |
| underscore: 'npm' | |
| jquery: 'local' | |
| 'jquery.cookie': 'local' | |
| 'jquery.easing': 'local' | |
| 'jquery.extend': 'local' | |
| 'jquery.reveal': 'local' | |
| 'jquery.simplemodal': 'local' | |
| backbone: 'npm' | |
| store: 'npm' | |
| 'date': 'local' | |
| 'hashgrid': 'local' | |
| 'backbone.history.html5': 'local' | |
| 'minpubsub': 'local' | |
| exports.js_target = 'frontend/js/libs.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
| fs = require 'fs' | |
| assets = require './frontend/js/assets' | |
| exec = require('child_process').exec | |
| task 'dev:js_lib', 'Rebuild the js libs', (options) -> | |
| js = '' | |
| js_local = assets.js_local | |
| for key of assets.js | |
| if assets.js[key] is "npm" | |
| try | |
| js += fs.readFileSync("node_modules/#{key}/#{key}.js", 'utf-8') | |
| catch e | |
| try | |
| # Try the lib dir | |
| js += fs.readFileSync("node_modules/#{key}/lib/#{key}.js", 'utf-8') | |
| catch e1 | |
| log "unable to find package #{key} in node_modules" | |
| else | |
| js += fs.readFileSync("#{js_local}/#{key}.js", 'utf-8') | |
| fs.writeFileSync assets.js_target, js | |
| console.log("Successfuly created #{assets.js_target}") | |
| task 'prod:js_lib', 'Build and uglify', -> | |
| invoke 'dev:js_lib' | |
| exec "uglifyjs --overwrite #{assets.js_target}", (err, stdout, stderr) -> | |
| if err then console.log stderr.trim() else console.log 'done' |
Author
Oh ok boss :). Added above.
Author
Btw, I dropped ender.js in favor of this. This is all I really need for the most part except for a little file watching when my app files change (just not packaging them for now).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
have you thought about integrating uglify here too?