sassc-rails
sassc-rails copied to clipboard
Add source map on debug mode with Sprockets 4
This fix https://github.com/sass/sassc-rails/issues/161. With Sprockets 4, when debug mode was enabled, the source map wasn't added correctly at the end of the file.
This branch does make SCSS sourcemaps work for me with sprockets 4 (in Rails).
Without the fix in this branch, dev tools debugging of SCSS was pretty impossible in sprockets 4; I had to disable source maps in my browser. (The source maps resulted in unusable mapping, where Chrome just though every line of CSS came from an @import statement, and I couldn't figure out how to disable source map generation altogether for sprockets).
Thanks @GCorbel, amazing work.
I would love to see this merged and in a sassc-rails release, so I can re-enable use of source maps in Chrome.
(Still very mystified why this hasn't been a higher-profile issue; is nobody else using SCSS and sprockets 4? That seems hard to believe, as they are both standard installs in a new rails app. Mystified!)
@jrochkind thanks for your review. I applied your comments and did some refactoring.
Would love to see this fix deployed in a new release. Debugging sass in a complex app is pretty painful as things stand.
I ran into this issue today, and fixed by using the code in this PR:
- Made my
Gemfilereference these commits:
gem 'sassc-rails', github: 'GCorbel/sassc-rails', branch: 'add-source-maps-on-debug'
- Changed
./config/environments/development.rbto have:
config.sass.inline_source_maps = true
config.assets.debug = true
rm -rf ./tmp/cachebased on the gem's README- Restarted my development server
- Now the Chrome Inspector directly links to the SCSS source.
I would +1 merging and cutting a new release, as a result.
(I am not a maintainer of this project, just a user.)