From 38e3c361f1f1b6e5a18ee6a7ae3458907f3af71a Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Sun, 12 Jul 2015 22:32:17 +0300 Subject: [PATCH] Fixed sourcemaps with different file.base --- index.js | 2 +- test/main.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 93f46c3..f881870 100644 --- a/index.js +++ b/index.js @@ -74,7 +74,7 @@ var gulpSass = function gulpSass(options, sync) { // Grab the stdout and transform it into stdin sassMapFile = sassMap.file.replace('stdout', 'stdin'); // Grab the base file name that's being worked on - sassFileSrc = file.path.split('/').pop(); + sassFileSrc = file.relative; // Replace the stdin with the original file name sassMap.sources[sassMap.sources.indexOf(sassMapFile)] = sassFileSrc; // Replace the map file with the original file name (but new extension) diff --git a/test/main.js b/test/main.js index 5c2ba60..5fe1a7b 100644 --- a/test/main.js +++ b/test/main.js @@ -415,6 +415,28 @@ describe('gulp-sass -- sync compile', function() { .on('end', done); }); + it('should work with gulp-sourcemaps and autoprefixer with different file.base', function(done) { + var expectedSources = [ + 'includes/_cats.scss', + 'includes/_dogs.sass', + 'scss/inheritance.scss' + ]; + + gulp.src(path.join(__dirname, '/scss/inheritance.scss'), { 'base': 'test' }) + .pipe(sourcemaps.init()) + .pipe(sass.sync()) + .pipe(tap(function(file) { + should.exist(file.sourceMap); + file.sourceMap.sources.should.eql(expectedSources); + })) + .pipe(postcss([autoprefixer()])) + .pipe(tap(function(file) { + should.exist(file.sourceMap); + file.sourceMap.sources.should.eql(expectedSources); + })) + .on('end', done); + }); + it('should work with empty files', function(done) { gulp.src(path.join(__dirname, '/scss/empty.scss')) .pipe(sass.sync())