joliss / broccoli-sass

Sass compiler for Broccoli, using libsass

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[RFC] Fix source maps

simonexmachina opened this issue · comments

Currently source maps don't really work in broccoli-sass.

There's two parts to this problem:

  1. Read: the ability to see the source SASS in dev tools
  2. Write: the ability to update the SASS in the dev tools, save your changes to the filesystem and have these changes written to the original source files

The current status is:

  • You can use broccoli-sass to generate source maps (node-sass provides source maps)
  • Unfortunately the mapping in the source map only map back to the source files as node-sass sees them, which may not be the original source files (ie. if you've used broccoli-merge-trees or any other compilation steps)
  • You can use the dev tools to create a mapping to the original source files, but the next time you start broccoli the directory path in tmp/ will have changed and the mapping no longer works.

There are a few potential solutions that have been investigated:

  1. Embed the sources in the source map using sourcesContent. This is supported in libsass now, but hasn't been exposed in node-sass. This solves the read problem, but not write. See this issue for status.
  2. Include the sources in the output tree, for example in output.css.sources/, and mutate the sources property in the source map so that they refer to this directory. This also solves the read problem, but not write. This is not necessary if option 1 works well.
  3. Create our own source map that provides the mapping from the sources files to the files that are provided to libsass and pass this to libsass, which would then append its own transformations to this file. This should allow the dev tools to map all the way back to the source files, which would solve the write problem. The developer would still need to use the workspaces feature to authorise the dev tools to write to the file system. See this issue for status on this.

We also need to make sure that paths come out correctly in devtools. I opened an issue on libsass: sass/libsass#908