22

In Google Chrome there are already sourcemaps for JS and CSS, CoffeeScript etc., and Paul Irish just demostrated SASS using sourcemaps.

It is a a technique to map development source files to the compiled results in the browser to allow navigating back to the source.

So, is there sourcemaps for HTML now? Languages like Jade, Slim really want such features so that people may debug them more easily.

Alex
  • 32,506
  • 16
  • 106
  • 171
jiyinyiyong
  • 4,586
  • 7
  • 45
  • 88
  • This would be super useful also in Magento where the webpage is generated from lots of .phtml files. +100000 – Alex May 24 '13 at 07:29
  • 1
    According to the specs of the source maps it *should* work - but no clue if anybody tried it: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/ – Alex May 24 '13 at 07:41
  • @Alex Could you hightlight the related sentence there? I searched `html` but not found any clear descriptions about that. – jiyinyiyong May 24 '13 at 08:12
  • 1
    "(although the format itself is language agnostic)." – Alex May 24 '13 at 08:17

2 Answers2

12

Sourcemaps, ready to use for HTML today no. This is also something very complex to implement.

This can change in future. If this response was marked as correct, and someone knows after some time that my answer is not more true, please comment below I'm wrong.

Emerson Rocha
  • 559
  • 9
  • 24
2

It is dead simnple to generate sourcemaps in a generic way like for css, but there is no browser support for it.

Some editors have plugins to support this. But be aware: this works best for static pages. (pug/jade, ... - using this at our place with nodejs+gulp)

BananaAcid
  • 3,221
  • 35
  • 38
  • Which editors / plugins support such? – Alex Oct 12 '22 at 18:09
  • 1
    @Alex For us it was https://github.com/sidorares/pugify ... and we used an experimental plugin that did behave like a developer inspector -- All gone I believe. For EJS,Haml,Markdown ... we used gulp + a sourcemap generator to create them, but parsing sourcemaps in browsers was not really picked up by any vendor -- we had a small tool where we entered the filename and line number to echo the line in question out to the terminal. Back then in 2017/2018. – BananaAcid Oct 15 '22 at 13:26