Skip to content

Commit

Permalink
suggestion to no use the sourceMapFileInline option
Browse files Browse the repository at this point in the history
When searching for a solution for gulp-community#126 i wondered why using Less with sourceMapFileInline (setting the SourceContent property of the source map with source files contents).

Not using the sourceMapFileInline and using `result.map` directly gives me the same results after some testing.
  • Loading branch information
bassjobsen committed Jan 24, 2015
1 parent abe34b1 commit 1339695
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,24 @@ module.exports = function (options) {
opts.filename = file.path;

// Bootstrap source maps.

if (file.sourceMap) {
opts.sourceMap = {
sourceMapFileInline: true
};
opts.sourceMap = {};
}

less.render(str, opts)
.then(function(result, opts){
var css = result.css;

file.contents = new Buffer(css);

file.contents = new Buffer(convert.removeComments(css));
file.path = gutil.replaceExtension(file.path, '.css');

if (file.sourceMap) {
var comment = convert.fromSource(css);
if (comment) {
file.contents = new Buffer(convert.removeComments(css));
var sourceMap = comment.sourcemap;
for (var i = 0; i < sourceMap.sources.length; i++) {
sourceMap.sources[i] = path.relative(file.base, sourceMap.sources[i]);
}
sourceMap.file = file.relative;
applySourceMap(file, sourceMap);
}
result.map = JSON.parse(result.map);
result.map.file = file.relative;
for (var i = 0; i < result.map.sources.length; i++) {
if(typeof result.map.sources[i] !== "undefined") result.map.sources[i] = path.relative(file.base, result.map.sources[i]);
}

cb(null, file);
}, function(err){
applySourceMap(file, result.map);
cb(null, file);
}, function(err){
// Convert the keys so PluginError can read them
err.lineNumber = err.line;
err.fileName = err.filename;
Expand Down

0 comments on commit 1339695

Please sign in to comment.