}, context);
importedData = rewriter.process(importedData);
}
- importedData = context.sourceTracker.store(path.resolve(context.relativeTo, fullPath), importedData);
+ importedData = context.sourceTracker.store(path.relative(context.root, fullPath), importedData);
if (mediaQuery.length > 0)
importedData = '@media ' + mediaQuery + '{' + importedData + '}';
rebaseTo = path.dirname(rebaseTo);
return function (relativeTo, sourcePath) {
- if (relativeTo)
- sourcePath = path.resolve(path.dirname(relativeTo), sourcePath);
-
- return path.relative(rebaseTo, sourcePath);
+ return relativeTo != sourcePath ?
+ path.normalize(path.join(path.dirname(relativeTo), sourcePath)) :
+ sourcePath;
};
}
} else {
var sourceFile = context.files[context.files.length - 1];
var sourceDir = sourceFile ? path.dirname(sourceFile) : self.options.relativeTo;
+ var fullPathToSourceFile = path.join(self.options.root, sourceDir || '', sourceMapFile);
- var inputMapData = fs.readFileSync(path.join(sourceDir || '', sourceMapFile), 'utf-8');
+ var inputMapData = fs.readFileSync(fullPathToSourceFile, 'utf-8');
self.maps[sourceFile || undefined] = new SourceMapConsumer(inputMapData);
}
}
styles = rewriter.process(styles);
if (outerContext.options.sourceMap && inputSourceMap) {
- var absoluteSource = path.resolve(source);
- styles = outerContext.sourceTracker.store(absoluteSource, styles);
- outerContext.inputSourceMapTracker.trackLoaded(absoluteSource, inputSourceMap);
+ styles = outerContext.sourceTracker.store(source, styles);
+ outerContext.inputSourceMapTracker.trackLoaded(source, inputSourceMap);
}
data.push(styles);
assert.deepEqual(
sourceMap.originalPositionFor({ line: 1, column: 1 }),
{
- source: '/fixtures/reset.css',
+ source: 'fixtures/reset.css',
line: 4,
column: 0,
name: null
},
'should have 2 mappings to styles.less file': function (minified) {
var stylesSource = minified.sourceMap._mappings._array.filter(function (mapping) {
- return mapping.source == 'styles.less';
+ return mapping.source == path.join('test', 'fixtures', 'source-maps', 'styles.less');
});
assert.lengthOf(stylesSource, 2);
}