Commit 2dfa9b20 authored by aberent's avatar aberent Committed by Commit bot

Remove minification spam

searchbox_api.js uses a Chrome extension to Javascript. This is not understood by the Closure compiler, so was giving errors when grit attempted to minify it. To prevent this don't minify this file.

BUG=644392

Review-Url: https://codereview.chromium.org/2337253002
Cr-Commit-Position: refs/heads/master@{#427033}
parent 82db1ff7
......@@ -343,8 +343,7 @@ def DoInline(
if not preprocess_only:
if strip_whitespace:
flat_text = minifier.Minify(flat_text,
os.path.splitext(input_filename)[1])
flat_text = minifier.Minify(flat_text, input_filename)
if not allow_external_script:
# We need to inline css and js before we inline images so that image
......
......@@ -3,7 +3,9 @@
# found in the LICENSE file.
"""Framework for stripping whitespace and comments from resource files"""
from os import path
import subprocess
import sys
__js_minifier = None
......@@ -13,18 +15,23 @@ def SetJsMinifier(minifier):
__js_minifier = minifier.split()
def Minify(source, file_type):
def Minify(source, filename):
file_type = path.splitext(filename)[1]
if not file_type == '.js' or not __js_minifier:
return source
# TODO (BUG http://crbug/644392) searchbox_api.js uses Chrome extensions so
# can't be minified. Remove this when that is fixed.
if path.abspath(filename).endswith(
'/chrome/renderer/resources/extensions/searchbox_api.js'):
return source
p = subprocess.Popen(
__js_minifier,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate(source)
if stderr:
print stderr
if p.returncode != 0:
print 'Minification failed, using original source'
return source
print 'Minification failed for %s' % filename
print stderr
sys.exit(p.returncode)
return stdout
......@@ -96,7 +96,7 @@ class IncludeNode(base.Node):
data = util.ReadFile(filename, util.BINARY)
# Note that the minifier will only do anything if a minifier command
# has been set in the command line.
data = minifier.Minify(data, os.path.splitext(filename)[1])
data = minifier.Minify(data, filename)
if 'compress' in self.attrs and self.attrs['compress'] == 'gzip':
# We only use rsyncable compression on Linux.
# We exclude ChromeOS since ChromeOS bots are Linux based but do not have
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment