Skip to content

Commit

Permalink
#52
Browse files Browse the repository at this point in the history
  • Loading branch information
scniro committed Apr 23, 2019
1 parent cde891e commit 0cffc4d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -55,7 +55,7 @@ module.exports = (options, callback) => {
const iMap = JSON.parse(css.sourceMap);
const oMap = Object.assign({}, iMap, {
file: path.relative(file.base, file.path),
sources: iMap.sources.map(() => path.relative(file.base, file.path))
sources: iMap.sources.map(mapSrc => path.relative(file.base, mapSrc))
});
applySourceMap(file, oMap);
}
Expand Down
18 changes: 18 additions & 0 deletions index.spec.js
Expand Up @@ -262,6 +262,24 @@ describe('gulp-clean-css: base functionality', () => {
done();
});
})

it('should write sourcemaps, correct source path', done => {
let maps = {};
gulp.src(['test/fixtures/sourcemaps-import/styles/main.css'], {base: 'test/fixtures/sourcemaps-import/styles'})
.pipe(sourcemaps.init())
.pipe(cleanCSS())
.pipe(sourcemaps.mapSources(function (sourcePath, file) {
maps[sourcePath] = true;
return sourcePath;
}))
.pipe(sourcemaps.write('./', {sourceRoot: '/'}))
.pipe(gulp.dest('test/fixtures/sourcemaps-import'))
.once('end', () => {
maps['main.css'].should.be.true;
maps['partial.css'].should.be.true;
done();
});
});
});

describe('gulp-clean-css: rebase', () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "gulp-clean-css",
"description": "Minify css with clean-css.",
"homepage": "https://github.com/scniro/gulp-clean-css#readme",
"version": "4.1.0",
"version": "4.1.1",
"author": "scniro",
"license": "MIT",
"bugs": {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/sourcemaps-import/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/fixtures/sourcemaps-import/main.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test/fixtures/sourcemaps-import/styles/main.css
@@ -0,0 +1,5 @@
@import(partial.css);

div {
margin:10;
}
3 changes: 3 additions & 0 deletions test/fixtures/sourcemaps-import/styles/partial.css
@@ -0,0 +1,3 @@
div {
color:red;
}

0 comments on commit 0cffc4d

Please sign in to comment.