I have an scss source file named style.scss
which resides within /style
:
@import 'reset';
body {
background: #555555;
color: white;
}
And another scss source file named reset.scss
which resides within /style
:
* {
padding: 0;
margin: 0;
}
These are compiled by sass with a source map in to style.min.css
which resides within /style
:
*{padding:0;margin:0}body{background:#555555;color:white}
/*# sourceMappingURL=style.min.css.map */
This is the resulting map file, style.min.css.map
which resides in /style
:
{"version":3,"sources":["reset.scss","style.scss"],"names":[],"mappings":"AAAA,CAAC,AAAC,CACA,OAAO,CAAE,CAAE,CACX,MAAM,CAAE,CAAE,CCAZ,ADCC,ICDG,AAAC,CACH,UAAU,CAAE,OAAQ,CACpB,KAAK,CAAE,KAAM,CACd","file":"style.min.css","sourcesContent":["* {\r\n padding: 0;\r\n margin: 0;\r\n}","@import 'reset';\r\n\r\nbody {\r\n background: #555555;\r\n color: white;\r\n}\r\n"],"sourceRoot":"/style"}
I am using gulp to invoke sass. Here is the relevant configuration:
var gulp = require('gulp');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
gulp.task('css', function() {
return gulp.src('style/style.scss')
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}))
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('.', {addComment: true, sourceRoot: '/style'}))
.pipe(gulp.dest('style/'))
});
WebStorm 11.0.1 seems to understand this perfectly.
Chrome DevTools fails to understand the mapping correctly. It is clearly trying; but all mappings point to reset.scss
in various locations rather than the correct file and location. If I manually combine both files by replacing the @import
with the actual content of reset.scss
, the mappings work correctly in chrome, pointing to the correct location within style.scss
.
Any idea what could be going on here?
EDIT: Microsoft Edge (the new IE in Windows 10) understands the mappings correctly within its in-browser dev tools.
EDIT 2: Firefox is experiencing the same issue as Chrome in exactly the same way.
EDIT 3: I Added another scss source file, test.scss
:
div {
color: red;
}
I then imported this in to the style.scss
file which now looks like this:
@import 'reset';
@import 'test';
body {
background: #555555;
color: white;
}
Chrome seems to understand that there are multiple source files, but the mapped locations aren't correct, and style.scss
is never pointed to.
Again, Edge and Webstorm work perfectly. Chrome and Firefox have the same issue.