Skip to content

Instantly share code, notes, and snippets.

@HendrikRunte
Last active October 17, 2018 01:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HendrikRunte/b3e6226576b9dde1ca23 to your computer and use it in GitHub Desktop.
Save HendrikRunte/b3e6226576b9dde1ca23 to your computer and use it in GitHub Desktop.
Sublime Build System for Google Closure Compiler with JS Source Maps
{
"cmd": [
"java",
"-jar",
"${packages}/Google Closure/compiler.jar",
"--js",
"$file",
"--js_output_file",
"$file_path/$file_base_name-compiled.js",
"--compilation_level",
"WHITESPACE_ONLY",
"--create_source_map",
"$file_base_name-compiled.js.map",
"--source_map_location_mapping",
"${file_path}|.",
"--output_wrapper",
"%output%\r\n//# sourceMappingURL=./$file_base_name-compiled.js.map"
],
"file_regex": "^(.*):([0-9]+):() ERROR - (.*)",
"selector": "source.js"
}
@HendrikRunte
Copy link
Author

In order to have a simple Build System for Sublime Text 3 which compiles JavaScript and creates a source map, create a new folder insider ~/Library/Application Support/Sublime Text 3/Packages called "Google Closure".

Download the latest Google Closure Compiler from Google: https://developers.google.com/closure/compiler/ unzip and place the file compiler.jar into your shiny new folder (see above).

Create a file named "Google Closure.sublime-build", put it into this folder as well and fill the file with the JSON above.

You can now use Google Closure Compiler to compile your *.js files and create sourceMaps.

@HendrikRunte
Copy link
Author

Update: Now it uses --output_wrapper and --source_map_location_mapping to notify browsers where to find the source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment