Permalink
Browse files

Add CSS minification + error handling

Error handling is kinda terribly implemented right now... I originally
let the underlying JS throw an error and then strip the message.
However, in some cases it seemed the V8 engine printed the original
error to the console anyway, so I opted for the messy variant in this
commit. Would ideally like to revisit.
  • Loading branch information...
1 parent da5b80f commit 958d46135d7eecf1228b25a2e6ccc7c7de8f5f7a @cjohansen cjohansen committed Nov 12, 2013
Showing with 3,976 additions and 27 deletions.
  1. +19 −0 build-js-sources.sh
  2. +0 −12 build-uglify.sh
  3. +1 −1 project.clj
  4. +3,889 −0 resources/csso.js
  5. +59 −11 src/optimus/minify.clj
  6. +8 −3 test/optimus/minify_test.clj
View
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+mkdir -p resources
+
+if [ ! -d "node_modules/uglify-js" ]; then
+ npm install uglify-js
+fi
+
+if [ ! -d "node_modules/csso" ]; then
+ npm install csso
+fi
+
+if [ ! -f "resources/uglify.js" ]; then
+ ./node_modules/.bin/uglifyjs --self -c -m -o resources/uglify.js
+fi
+
+if [ ! -f "resources/csso.js" ]; then
+ cp ./node_modules/csso/web/csso.web.js resources/csso.js
+fi
View
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-mkdir -p resources
-
-if [ ! -d "node_modules" ]; then
- npm install
-fi
-
-if [ ! -f "resources/uglify.js" ]; then
- ./node_modules/.bin/uglifyjs --self -c -m -o resources/uglify.js
-fi
-
View
@@ -11,4 +11,4 @@
:plugins [[lein-midje "3.0.0"]
[lein-shell "0.3.0"]]
:resource-paths ["test/resources"]}}
- :prep-tasks [["shell" "./build-uglify.sh"]])
+ :prep-tasks [["shell" "./build-js-sources.sh"]])
Oops, something went wrong. Retry.

2 comments on commit 958d461

@magnars
Owner

csso has optional structural optimizations. Are these on or off now?

@cjohansen
Collaborator

I have no idea. Will look into it tomorrow.

Please sign in to comment.