Merge pull request #320 from martinoconnor/master
Modify sourcemap paths of imported files
This commit is contained in:
commit
64d93e6945
15
index.js
15
index.js
|
@ -57,6 +57,7 @@ var gulpSass = function gulpSass(options, sync) {
|
||||||
if (file.sourceMap) {
|
if (file.sourceMap) {
|
||||||
opts.sourceMap = file.path;
|
opts.sourceMap = file.path;
|
||||||
opts.omitSourceMapUrl = true;
|
opts.omitSourceMapUrl = true;
|
||||||
|
opts.sourceMapContents = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
@ -65,7 +66,9 @@ var gulpSass = function gulpSass(options, sync) {
|
||||||
filePush = function filePush(sassObj) {
|
filePush = function filePush(sassObj) {
|
||||||
var sassMap,
|
var sassMap,
|
||||||
sassMapFile,
|
sassMapFile,
|
||||||
sassFileSrc;
|
sassFileSrc,
|
||||||
|
sassFileSrcPath,
|
||||||
|
sourceFileIndex;
|
||||||
|
|
||||||
// Build Source Maps!
|
// Build Source Maps!
|
||||||
if (sassObj.map) {
|
if (sassObj.map) {
|
||||||
|
@ -75,6 +78,16 @@ var gulpSass = function gulpSass(options, sync) {
|
||||||
sassMapFile = sassMap.file.replace('stdout', 'stdin');
|
sassMapFile = sassMap.file.replace('stdout', 'stdin');
|
||||||
// Grab the base file name that's being worked on
|
// Grab the base file name that's being worked on
|
||||||
sassFileSrc = file.relative;
|
sassFileSrc = file.relative;
|
||||||
|
// Grab the path portion of the file that's being worked on
|
||||||
|
sassFileSrcPath = path.dirname(sassFileSrc);
|
||||||
|
if (sassFileSrcPath) {
|
||||||
|
//Prepend the path to all files in the sources array except the file that's being worked on
|
||||||
|
for (sourceFileIndex = 0; sourceFileIndex < sassMap.sources.length; sourceFileIndex++) {
|
||||||
|
if (sourceFileIndex !== sassMap.sources.indexOf(sassMapFile)) {
|
||||||
|
sassMap.sources[sourceFileIndex] = path.join(sassFileSrcPath, sassMap.sources[sourceFileIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Replace the stdin with the original file name
|
// Replace the stdin with the original file name
|
||||||
sassMap.sources[sassMap.sources.indexOf(sassMapFile)] = sassFileSrc;
|
sassMap.sources[sassMap.sources.indexOf(sassMapFile)] = sassFileSrc;
|
||||||
// Replace the map file with the original file name (but new extension)
|
// Replace the map file with the original file name (but new extension)
|
||||||
|
|
|
@ -438,8 +438,8 @@ describe('gulp-sass -- sync compile', function() {
|
||||||
|
|
||||||
it('should work with gulp-sourcemaps and autoprefixer with different file.base', function(done) {
|
it('should work with gulp-sourcemaps and autoprefixer with different file.base', function(done) {
|
||||||
var expectedSources = [
|
var expectedSources = [
|
||||||
'includes/_cats.scss',
|
'scss/includes/_cats.scss',
|
||||||
'includes/_dogs.sass',
|
'scss/includes/_dogs.sass',
|
||||||
'scss/inheritance.scss'
|
'scss/inheritance.scss'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue