Commit df4e128afb8559e9693292ac0f6c72e1a2b9dd09

Thomas de Grivel 2015-06-20T07:25:31

Use UglifyJS for assets compilation.

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"