Index: grit/format/data_pack.py |
diff --git a/grit/format/data_pack.py b/grit/format/data_pack.py |
index 02616c39d40443d1c583f3acb351c7708f13ec54..9f85bb025eac66b478f711d748eb33047aa2a721 100755 |
--- a/grit/format/data_pack.py |
+++ b/grit/format/data_pack.py |
@@ -7,6 +7,11 @@ |
files. |
""" |
+import os |
+import sys |
+ |
+import rjsmin |
+ |
import collections |
import exceptions |
import os |
@@ -43,6 +48,17 @@ def Format(root, lang='en', output_dir='.'): |
if isinstance(node, (include.IncludeNode, message.MessageNode, |
structure.StructureNode)): |
id, value = node.GetDataPackPair(lang, UTF8) |
+ txt_id = node.GetTextualIds()[0] |
+ |
+ # Use rjsmin to compress JavaScript resources. Closure would |
+ # be even better but is tricky to integrate into the build |
+ # system since it is Java. |
+ if "_JS" in txt_id[-3:]: |
+ size = len(value) |
+ packed_value = rjsmin.jsmin(value) |
+ packed_size = len(packed_value) |
+ if packed_size < size: |
+ value = packed_value |
if value is not None: |
data[id] = value |
return WriteDataPackToString(data, UTF8) |