Permalink
Browse files

Merge pull request #12 from gkoberger/master

CSS Minifier, Round 2
  • Loading branch information...
2 parents bcb6a2b + 87a07ea commit 4d5cb9a7d577944cad6448de718f99dc0eced994 @davedash davedash committed Sep 21, 2011
Showing with 33 additions and 7 deletions.
  1. +23 −3 README.rst
  2. +10 −4 jingo_minify/management/commands/compress_assets.py
View
@@ -13,11 +13,13 @@ Installing Jingo Minify
Requirements
------------
-* **Java**. Jingo Minify uses the YUICompressor internally.
* **Jingo and Jinja2**. Jingo Minify is not designed for Django templates.
-Optionally:
+One of the following:
+* **Java**. If you want to use YUI Compressor
+* **NodeJS**. If you want to use UglifyJS and Clean-CSS
+Optionally:
* **less**. Jingo Minify supports less_, if you have ``lessc`` available.
@@ -30,7 +32,11 @@ Configure the following settings::
JAVA_BIN = '/path/to/java'
# If you want to use less, set this:
- LESS_BIN = '/path/to/lessc'
+ LESS_BIN = '/path/to/lessc' # Probably just 'lessc'
+
+ # If you want to use node-based minifiers, set these:
+ UGLIFYJS_BIN = '/path/to/uglifyjs' # Probably just 'uglify'
+ CLEANCSS_BIN = '/path/to/cleancss' # Probably just 'cleancss'
# Add jingo_minify to INSTALLED_APPS
INSTALLED_APPS = (
@@ -138,6 +144,18 @@ file called ``build.py`` along side ``manage.py`` that contains unique IDs
based on the SHA of the current git checkout.
+Minifier Options
+----------------
+
+You can choose between YUICompressor (Java) or UglifyJS/clean-css (node) for
+minifying. You don't have to do anything to get YUICompressor working.
+
+If you want to use the node counterparts, just add `UGLIFYJS_BIN` and
+`CLEANCSS_BIN` (set to the correct paths, of course) to your settings.py.
+You can see the actual syntax if you look at the Installation section of this
+README.
+
+
Cache Busting Individual Images
==============================
@@ -181,3 +199,5 @@ automatically in a few ways.
.. _Jinja2: http://jinja.pocoo.org/docs/
.. _Django: https://www.djangoproject.com/
.. _less: http://lesscss.org/
+.. _UglifyJS: https://github.com/mishoo/UglifyJS
+.. _clean-css: https://github.com/GoalSmashers/clean-css
@@ -104,13 +104,19 @@ def handle(self, **options):
# Compresses the concatenation.
if ftype == 'js' and hasattr(settings, 'UGLIFY_BIN'):
- call("%s %s -nc %s > %s" % (settings.UGLIFY_BIN, v,
- concatted_file,
- compressed_file),
+ print "Minifying %s (using UglifyJS)" % concatted_file
+ call("%s %s -nc -o %s %s" % (settings.UGLIFY_BIN, v,
+ compressed_file, concatted_file),
+ shell=True, stdout=PIPE)
+ if ftype == 'css' and hasattr(settings, 'CLEANCSS_BIN'):
+ print "Minifying %s (using clean-css)" % concatted_file
+ call("%s -o %s %s" % (settings.CLEANCSS_BIN,
+ compressed_file, concatted_file),
shell=True, stdout=PIPE)
else:
+ print "Minifying %s (using YUICompressor)" % concatted_file
call("%s -jar %s %s %s -o %s" % (settings.JAVA_BIN,
- path_to_jar, v, concatted_file, compressed_file),
+ path_to_jar, v, concatted_file, compressed_file),
shell=True, stdout=PIPE)
self.update_hashes(bundle_hashes=bundle_hashes)

0 comments on commit 4d5cb9a

Please sign in to comment.