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( ...@@ -343,8 +343,7 @@ def DoInline(
if not preprocess_only: if not preprocess_only:
if strip_whitespace: if strip_whitespace:
flat_text = minifier.Minify(flat_text, flat_text = minifier.Minify(flat_text, input_filename)
os.path.splitext(input_filename)[1])
if not allow_external_script: if not allow_external_script:
# We need to inline css and js before we inline images so that image # We need to inline css and js before we inline images so that image
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
# found in the LICENSE file. # found in the LICENSE file.
"""Framework for stripping whitespace and comments from resource files""" """Framework for stripping whitespace and comments from resource files"""
from os import path
import subprocess import subprocess
import sys
__js_minifier = None __js_minifier = None
...@@ -13,18 +15,23 @@ def SetJsMinifier(minifier): ...@@ -13,18 +15,23 @@ def SetJsMinifier(minifier):
__js_minifier = minifier.split() __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: if not file_type == '.js' or not __js_minifier:
return source 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( p = subprocess.Popen(
__js_minifier, __js_minifier,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate(source) (stdout, stderr) = p.communicate(source)
if stderr:
print stderr
if p.returncode != 0: if p.returncode != 0:
print 'Minification failed, using original source' print 'Minification failed for %s' % filename
return source print stderr
sys.exit(p.returncode)
return stdout return stdout
...@@ -96,7 +96,7 @@ class IncludeNode(base.Node): ...@@ -96,7 +96,7 @@ class IncludeNode(base.Node):
data = util.ReadFile(filename, util.BINARY) data = util.ReadFile(filename, util.BINARY)
# Note that the minifier will only do anything if a minifier command # Note that the minifier will only do anything if a minifier command
# has been set in the command line. # 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': if 'compress' in self.attrs and self.attrs['compress'] == 'gzip':
# We only use rsyncable compression on Linux. # We only use rsyncable compression on Linux.
# We exclude ChromeOS since ChromeOS bots are Linux based but do not have # 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