Skip to content

Commit 0cffc4d

Browse files
committed
1 parent cde891e commit 0cffc4d

File tree

7 files changed

+31
-2
lines changed

7 files changed

+31
-2
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = (options, callback) => {
5555
const iMap = JSON.parse(css.sourceMap);
5656
const oMap = Object.assign({}, iMap, {
5757
file: path.relative(file.base, file.path),
58-
sources: iMap.sources.map(() => path.relative(file.base, file.path))
58+
sources: iMap.sources.map(mapSrc => path.relative(file.base, mapSrc))
5959
});
6060
applySourceMap(file, oMap);
6161
}

index.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,24 @@ describe('gulp-clean-css: base functionality', () => {
262262
done();
263263
});
264264
})
265+
266+
it('should write sourcemaps, correct source path', done => {
267+
let maps = {};
268+
gulp.src(['test/fixtures/sourcemaps-import/styles/main.css'], {base: 'test/fixtures/sourcemaps-import/styles'})
269+
.pipe(sourcemaps.init())
270+
.pipe(cleanCSS())
271+
.pipe(sourcemaps.mapSources(function (sourcePath, file) {
272+
maps[sourcePath] = true;
273+
return sourcePath;
274+
}))
275+
.pipe(sourcemaps.write('./', {sourceRoot: '/'}))
276+
.pipe(gulp.dest('test/fixtures/sourcemaps-import'))
277+
.once('end', () => {
278+
maps['main.css'].should.be.true;
279+
maps['partial.css'].should.be.true;
280+
done();
281+
});
282+
});
265283
});
266284

267285
describe('gulp-clean-css: rebase', () => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gulp-clean-css",
33
"description": "Minify css with clean-css.",
44
"homepage": "https://github.com/scniro/gulp-clean-css#readme",
5-
"version": "4.1.0",
5+
"version": "4.1.1",
66
"author": "scniro",
77
"license": "MIT",
88
"bugs": {

test/fixtures/sourcemaps-import/main.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/sourcemaps-import/main.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import(partial.css);
2+
3+
div {
4+
margin:10;
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
div {
2+
color:red;
3+
}

0 commit comments

Comments
 (0)