Use UglifyJS for assets compilation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/js.lisp b/js.lisp
index 2198154..489bed4 100644
--- a/js.lisp
+++ b/js.lisp
@@ -40,6 +40,15 @@
;; Compile
+(defun uglifyjs (in out)
+ (write-string
+ (uglify-js:ast-gen-code
+ (uglify-js:ast-mangle
+ (uglify-js:ast-squeeze
+ (parse-js:parse-js in)))
+ :beautify nil)
+ out))
+
(defun jsmin (in out)
(let ((err (make-string-output-stream)))
(unwind-protect
@@ -56,3 +65,11 @@
(copy-stream js output))
(force-output output)
(values))
+
+(defmethod compile-asset ((asset js-asset) (output stream))
+ (with-temporary-file (tmp)
+ (call-next-method asset tmp)
+ (force-output tmp)
+ (file-position tmp 0)
+ (uglifyjs tmp output))
+ (values))
diff --git a/rol-assets.asd b/rol-assets.asd
index 1e3e775..f112b65 100644
--- a/rol-assets.asd
+++ b/rol-assets.asd
@@ -32,6 +32,7 @@
"cfg"
"cl-debug"
"cl-fad"
+ "cl-uglify-js"
"closer-mop"
"cl-json"
"exec-js"