Created
November 22, 2012 19:49
-
-
Save garth/4132681 to your computer and use it in GitHub Desktop.
Use snockets to package javascript files for debug output (with //@ sourceURL)
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
#entry point for js/coffee dependency tree | |
rootfile = 'root.js' | |
#get the file names and content | |
files = snockets.getCompiledChain rootfile, { async: false } | |
#package each file in eval with trailing //@ sourceURL | |
scripts = [] | |
for file in files | |
script = file.js.replace(/\\/g, '\\\\').replace(/\n/g, '\\n').replace(/'/g, '\\\'') | |
name = path.relative(path.dirname(@filename), file.filename) | |
scripts.push "// #{name}\neval('#{script}\\n//@ sourceURL=#{name}')\n" | |
# join scripts into single package ready to be sent to the client | |
jsPackage = scripts.join('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment