From 132686b4a77d577942d199cf03b5f37985310773 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 11 Sep 2014 12:11:14 +0200 Subject: [PATCH 1/2] Generate source map of minified ol.js Allows automatic unminification by the browser. A postprocessing is required to: - fix the paths to the sources; - add the link from the minified script to its map. If someone knows how to do the first item in Python or nodejs, please provide a patch. A simple shell script is: ``` \#!/bin/sh pwd=`pwd` sed -i "s!$pwd/build!olsource!g" 'build/ol.js.map' sed -i "s!$pwd!olsource!g" 'build/ol.js.map' ``` The second item should always be manually handled to avoid 404 errors in debuggers `echo '//# sourceMappingURL=ol.js.map' >> build/ol.js` Finally, create an alias / copy ol3 directory to /olsource in your deployed environment. --- config/ol.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/ol.json b/config/ol.json index 5b09d266f6..c74879e641 100644 --- a/config/ol.json +++ b/config/ol.json @@ -61,6 +61,8 @@ "compilation_level": "ADVANCED", "warning_level": "VERBOSE", "use_types_for_optimization": true, - "manage_closure_dependencies": true + "manage_closure_dependencies": true, + "create_source_map": "build/ol.js.map", + "source_map_format": "V3" } } From 2ef83021225bb5451c8c3971aaeb9e32cdd97b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 9 Jan 2015 12:16:00 +0100 Subject: [PATCH 2/2] Add a build/ol.js.map target --- build.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 9b5348459d..603a9757dc 100755 --- a/build.py +++ b/build.py @@ -172,7 +172,8 @@ virtual('ci', 'lint', 'build', 'test', 'build/examples/all.combined.js', 'check-examples', 'apidoc') -virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-debug.js') +virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-debug.js', + 'build/ol.js.map') virtual('check', 'lint', 'build/ol.js', 'test') @@ -192,12 +193,21 @@ def build_ol_css(t): t.output('%(CLEANCSS)s', 'css/ol.css') -@target('build/ol.js', SRC, SHADER_SRC, 'config/ol.json', NPM_INSTALL) -def build_ol_new_js(t): +def _build_js(t): t.run('node', 'tasks/build.js', 'config/ol.json', 'build/ol.js') + + +@target('build/ol.js', SRC, SHADER_SRC, 'config/ol.json', NPM_INSTALL) +def build_ol_js(t): + _build_js(t) report_sizes(t) +@target('build/ol.js.map', SRC, SHADER_SRC, 'config/ol.json', NPM_INSTALL) +def build_ol_js_map(t): + _build_js(t) + + @target('build/ol-debug.js', SRC, SHADER_SRC, 'config/ol-debug.json', NPM_INSTALL) def build_ol_debug_js(t):