function runMinifier(callback, self) {
return function (data) {
- self.inputSourceMapTracker = new InputSourceMapTracker(self.options).track(data);
+ if (self.options.sourceMap)
+ self.inputSourceMapTracker = new InputSourceMapTracker(self.options).track(data);
data = self.options.debug ?
minifyWithDebug(self, data) :
InputSourceMapStore.prototype.track = function (data) {
if (typeof this.options.sourceMap == 'string') {
this.maps[undefined] = new SourceMapConsumer(this.options.sourceMap);
- this.options.sourceMap = true;
return this;
}
} else if (nextAt == mapMatch.index) {
var inputMapData = fs.readFileSync(path.join(this.options.root || '', mapMatch[1]), 'utf-8');
this.maps[files[files.length - 1] || undefined] = new SourceMapConsumer(inputMapData);
- this.options.sourceMap = true;
}
cursor += nextAt + 1;
}
},
'input map from source': {
- 'topic': new CleanCSS().minify('div > a {\n color: red;\n}/*# sourceMappingURL=' + inputMapPath + ' */'),
+ 'topic': new CleanCSS({ sourceMap: true }).minify('div > a {\n color: red;\n}/*# sourceMappingURL=' + inputMapPath + ' */'),
'should have 2 mappings': function (minified) {
assert.equal(2, minified.sourceMap._mappings.length);
},
}
},
'input map from source with root': {
- 'topic': new CleanCSS({ root: path.dirname(inputMapPath) }).minify('div > a {\n color: red;\n}/*# sourceMappingURL=styles.css.map */'),
+ 'topic': new CleanCSS({ sourceMap: true, root: path.dirname(inputMapPath) }).minify('div > a {\n color: red;\n}/*# sourceMappingURL=styles.css.map */'),
'should have 2 mappings': function (minified) {
assert.equal(2, minified.sourceMap._mappings.length);
},
}
},
'complex input map': {
- 'topic': new CleanCSS({ root: path.dirname(inputMapPath) }).minify('@import url(import.css);'),
+ 'topic': new CleanCSS({ sourceMap: true, root: path.dirname(inputMapPath) }).minify('@import url(import.css);'),
'should have 4 mappings': function (minified) {
assert.equal(4, minified.sourceMap._mappings.length);
},