Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1455)

Unified Diff: Source/web/scripts/make-file-arrays.py

Issue 252633006: Compact JS resource better by using rjsmin. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Source/build/scripts/rjsmin.py ('K') | « Source/devtools/scripts/rjsmin.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/scripts/make-file-arrays.py
diff --git a/Source/web/scripts/make-file-arrays.py b/Source/web/scripts/make-file-arrays.py
index 21ee6fbd26ef2e05e97136c710aae8b1e0e10bdf..be70a9bf804f154e45265925a2fc90b5e69cd2e6 100755
--- a/Source/web/scripts/make-file-arrays.py
+++ b/Source/web/scripts/make-file-arrays.py
@@ -34,6 +34,15 @@ import re
import sys
from optparse import OptionParser
+rjsmin_path = os.path.abspath(os.path.join(
+ os.path.dirname(__file__),
+ "..",
+ "..",
+ "build",
+ "scripts"))
+sys.path.append(rjsmin_path)
+import rjsmin
+
def make_variable_name_and_read(file_name):
result = re.match(r'([\w\d_]+)\.([\w\d_]+)', os.path.basename(file_name))
@@ -53,21 +62,13 @@ def strip_whitespace_and_comments(file_name, content):
sys.exit(1)
extension = result.group(1).lower()
multi_line_comment = re.compile(r'/\*.*?\*/', re.MULTILINE | re.DOTALL)
- single_line_comment = re.compile(r'^//.*$', re.MULTILINE)
# Don't accidentally match URLs (http://...)
- trailing_comment = re.compile(r'([^:])//.*$', re.MULTILINE)
repeating_space = re.compile(r'[ \t]+', re.MULTILINE)
leading_space = re.compile(r'^[ \t]+', re.MULTILINE)
trailing_space = re.compile(r'[ \t]+$', re.MULTILINE)
empty_line = re.compile(r'\n+')
if extension == 'js':
- content = multi_line_comment.sub('', content)
- content = single_line_comment.sub('', content)
- content = trailing_comment.sub(r'\1', content)
- content = repeating_space.sub(' ', content)
- content = leading_space.sub('', content)
- content = trailing_space.sub('', content)
- content = empty_line.sub('\n', content)
abarth-chromium 2014/04/26 17:08:36 It replaces this one, but may this one is too simp
+ content = rjsmin.jsmin(content)
elif extension == 'css':
content = multi_line_comment.sub('', content)
content = repeating_space.sub(' ', content)
« Source/build/scripts/rjsmin.py ('K') | « Source/devtools/scripts/rjsmin.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698