| Index: tools/grit/grit/format/minifier.py
|
| diff --git a/tools/grit/grit/format/minifier.py b/tools/grit/grit/format/minifier.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fed85f179e7b83678d64cc42e6e187dfc67ee3d2
|
| --- /dev/null
|
| +++ b/tools/grit/grit/format/minifier.py
|
| @@ -0,0 +1,29 @@
|
| +# Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +'''Framework for stripping whitespace and comments from resource files'''
|
| +
|
| +import re
|
| +import subprocess
|
| +
|
| +__js_minifier = None
|
| +
|
| +def SetJsMinifier(minifier):
|
| + global __js_minifier
|
| + __js_minifier = minifier
|
| +
|
| +
|
| +def Minify(source, file_type):
|
| + if file_type == '.js' and __js_minifier:
|
| + p = subprocess.Popen(__js_minifier,
|
| + stdin=subprocess.PIPE,
|
| + stdout=subprocess.PIPE,
|
| + stderr=subprocess.PIPE)
|
| + (stdout,stderr) = p.communicate(source)
|
| + if stderr:
|
| + print stderr
|
| + return stdout
|
| + else:
|
| + return source
|
| +
|
|
|