You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created an issue for gulp-sourcemaps yesterday, but after some investigation, I believe this is an issue with gulp-sass. First, I'll quote my original ticket:
I've been having a problem with blank source .scss files in Chrome's debugger. For a set of files I grab with gulp.src('somedir/**/*.scss'), I'm writing external sourcemaps with includeContent left to true (though I've also tried setting it explicitly). Files in the root directory have their sources included properly, but for any files in subdirectories, their source code is missing ("sourcesContent":[null]).
I created a brand-new project with nothing extraneous and had the same problem:
gulpfile:
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('default', function () {
return gulp.src('src/scss/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('build/css'));
});
There are two .scss files:
src/scss/app.scss and src/scss/foo/bar.scss
When I run gulp, it properly generates these files:
build/css/app.css build/css/app.css.map build/css/foo/bar.css and build/css/foo/bar.css.map
app.css.map contains the proper sourcesContent, but foo/bar.css.map has "sourcesContent":[null].
Any idea what could be going on? Is there an option I'm missing that I need to set? Thanks in advance for any help you can provide!
After some investigation, I found that the problem is happening at line 79 of index.js, when the vinyl-sourcemaps-apply module is called.
The problem seems to be that when it's called for sass files in child directories, file.sourceMap.sources === ['foo/bar.scss'], but sassMap.sources === ['bar.scss'] because of line 73.
At some point in source-map, the sourcesContent gets discarded and set to null because its key (foo/bar.scss) doesn't match the key it's dealing with (bar.scss).
This problem can be fixed by replacing line 75 of index.js with these two lines:
var sourceIndex = sassMap.sources.indexOf(sassMapFile);
sassMap.sources[sourceIndex] = file.sourceMap.sources[sourceIndex];
This resolves the problem, though I'd, of course, need your thoughts and approval to make sure it doesn't impact anything I might not be thinking about. I'm happy to submit this as a pull request if desired, but your admirably clear contribution guidelines made me stop and make this an issue instead.
The text was updated successfully, but these errors were encountered:
Any thoughts on this? It's possible not that many projects want to compile a globbed source, but it'd definitely be useful for us to make this fix, barring any objection. 😄
I created an issue for
gulp-sourcemaps
yesterday, but after some investigation, I believe this is an issue withgulp-sass
. First, I'll quote my original ticket:I've been having a problem with blank source
.scss
files in Chrome's debugger. For a set of files I grab withgulp.src('somedir/**/*.scss')
, I'm writing external sourcemaps withincludeContent
left to true (though I've also tried setting it explicitly). Files in the root directory have their sources included properly, but for any files in subdirectories, their source code is missing ("sourcesContent":[null]
).I created a brand-new project with nothing extraneous and had the same problem:
gulpfile:
There are two
.scss
files:src/scss/app.scss
andsrc/scss/foo/bar.scss
When I run gulp, it properly generates these files:
build/css/app.css
build/css/app.css.map
build/css/foo/bar.css
andbuild/css/foo/bar.css.map
app.css.map
contains the propersourcesContent
, butfoo/bar.css.map
has"sourcesContent":[null]
.Any idea what could be going on? Is there an option I'm missing that I need to set? Thanks in advance for any help you can provide!
P.S.
node --version
→ v.0.12.0After some investigation, I found that the problem is happening at line 79 of
index.js
, when thevinyl-sourcemaps-apply
module is called.The problem seems to be that when it's called for sass files in child directories,
file.sourceMap.sources === ['foo/bar.scss']
, butsassMap.sources === ['bar.scss']
because of line 73.At some point in source-map, the
sourcesContent
gets discarded and set to null because its key (foo/bar.scss
) doesn't match the key it's dealing with (bar.scss
).This problem can be fixed by replacing line 75 of
index.js
with these two lines:This resolves the problem, though I'd, of course, need your thoughts and approval to make sure it doesn't impact anything I might not be thinking about. I'm happy to submit this as a pull request if desired, but your admirably clear contribution guidelines made me stop and make this an issue instead.
The text was updated successfully, but these errors were encountered: