Source maps
Gary Poster
gary.poster at canonical.com
Tue Jan 29 17:02:43 UTC 2013
On 01/29/2013 11:10 AM, Benji York wrote:
> Here are a few things I found when I went on a source-maps-laden tangent
> recently.
Thank you very much for writing this up, Benji.
>
>
> Enabling Source Maps
>
> Chrom[e|ium] has source map support but it must be enabled. Here is a
> quick demo of how to do so and how the result looks:
> https://www.youtube.com/watch?v=-xJl22Kvgjg
>
>
> Minifier Options
>
> The JS minifier we use (uglify) supports source maps, to enable them we
> have to pass some command line options:
>
> --source-map SOURCE_MAP_NAME --prefix=3 --source-map-root=app
>
> In my testing SOURCE_MAP_NAME was either all-yui-source-map or
> app-source-map, mirroring the two files we combine all our JS into. For
> simplicity we may want to transition to just putting everything into a
> single file when we enable source maps.
In the past, Kapil has expressed a strong preference for multiple files.
Assuming he still feels that way, this is still pretty easy to do for
each file, right?
>
> The uglify help is reasonably good at explaining what these options do:
>
> --source-map Specify an output file where to generate source map.
> [string]
> --source-map-root The path to the original source to be included in the
> source map. [string]
> --in-source-map Input source map, useful if you're compressing JS that was
> generated from some other original code.
> -p, --prefix Skip prefix for original filenames that appear in source
> maps. For example -p 3 will drop 3 directories from file
> names and ensure they are relative paths.
>
> Note that if we ever start using something that generates JS
> (e.g., CoffeeScript) that also generates source maps, we can use the
> --in-source-map option to map through the minification and JS generated
> by that process, all the way back to the real source code.
>
>
> Serving the Source
>
> Since the browser displays the original source code, we will have to
> serve that source code. The simplest thing would be to expose the "app"
> directory structure under /app in the HTTP server.
I still wish the app directory looked more like the layout in
build-debug--that is, closer to what we actually serve. :-/
Thanks again
Gary
More information about the Juju-GUI
mailing list