OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 with tempfile.NamedTemporaryFile(mode='wt+', delete=False) as tmp: | 78 with tempfile.NamedTemporaryFile(mode='wt+', delete=False) as tmp: |
79 # Grit includes are not supported, use HTML imports instead. | 79 # Grit includes are not supported, use HTML imports instead. |
80 tmp.write(output.replace( | 80 tmp.write(output.replace( |
81 '<include src="', '<include src-disabled="')) | 81 '<include src="', '<include src-disabled="')) |
82 | 82 |
83 try: | 83 try: |
84 _run_cmd(['crisper', '--source', tmp.name, | 84 _run_cmd(['crisper', '--source', tmp.name, |
85 '--script-in-head', 'false', | 85 '--script-in-head', 'false', |
86 '--html', html_out_path, | 86 '--html', html_out_path, |
87 '--js', js_out_path]) | 87 '--js', js_out_path]) |
| 88 |
| 89 # TODO(tsergeant): Remove when JS resources are minified by default: |
| 90 # crbug.com/619091. |
| 91 _run_cmd(['uglifyjs', js_out_path, |
| 92 '--beautify', 'indent-level=2,quote_style=3', |
| 93 '--comments', '/Copyright|license|LICENSE|\<\/?if/', |
| 94 '--output', js_out_path]) |
88 finally: | 95 finally: |
89 os.remove(tmp.name) | 96 os.remove(tmp.name) |
90 | 97 |
91 | 98 |
92 def main(): | 99 def main(): |
93 _vulcanize(directory='md_downloads', host='downloads', | 100 _vulcanize(directory='md_downloads', host='downloads', |
94 html_in_file='downloads.html') | 101 html_in_file='downloads.html') |
95 | 102 |
96 # Already loaded by history.html: | 103 # Already loaded by history.html: |
97 history_extra_args = ['--exclude', 'chrome://resources/html/util.html', | 104 history_extra_args = ['--exclude', 'chrome://resources/html/util.html', |
98 '--exclude', 'chrome://history/constants.html'] | 105 '--exclude', 'chrome://history/constants.html'] |
99 _vulcanize(directory='md_history', host='history', html_in_file='app.html', | 106 _vulcanize(directory='md_history', host='history', html_in_file='app.html', |
100 html_out_file='app.vulcanized.html', js_out_file='app.crisper.js', | 107 html_out_file='app.vulcanized.html', js_out_file='app.crisper.js', |
101 extra_args=history_extra_args) | 108 extra_args=history_extra_args) |
102 | 109 |
103 | 110 |
104 if __name__ == '__main__': | 111 if __name__ == '__main__': |
105 main() | 112 main() |
OLD | NEW |