From 855eca1d93caa231374096444322b21e8b86b4ba Mon Sep 17 00:00:00 2001 From: Kevin Attfield Date: Tue, 29 Oct 2013 11:12:50 -0700 Subject: [PATCH] added sourceMappingURL option --- bin/lessc | 1 + lib/less/parser.js | 1 + lib/less/source-map-output.js | 10 ++++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/lessc b/bin/lessc index 94c5dd61..41e1e8e3 100755 --- a/bin/lessc +++ b/bin/lessc @@ -318,6 +318,7 @@ var parseLessFile = function (e, data) { cleancss: options.cleancss, sourceMap: Boolean(options.sourceMap), sourceMapFilename: options.sourceMap, + sourceMappingURL: options.sourceMappingURL, sourceMapOutputFilename: options.sourceMapOutputFilename, sourceMapBasepath: options.sourceMapBasepath, sourceMapRootpath: options.sourceMapRootpath || "", diff --git a/lib/less/parser.js b/lib/less/parser.js index 090e305f..244eead7 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -469,6 +469,7 @@ less.Parser = function Parser(env) { rootNode: evaldRoot, contentsMap: parser.imports.contents, sourceMapFilename: options.sourceMapFilename, + sourceMappingURL: options.sourceMappingURL, outputFilename: options.sourceMapOutputFilename, sourceMapBasepath: options.sourceMapBasepath, sourceMapRootpath: options.sourceMapRootpath, diff --git a/lib/less/source-map-output.js b/lib/less/source-map-output.js index b3e142bf..f56035c8 100644 --- a/lib/less/source-map-output.js +++ b/lib/less/source-map-output.js @@ -7,6 +7,7 @@ this._contentsMap = options.contentsMap; this._sourceMapFilename = options.sourceMapFilename; this._outputFilename = options.outputFilename; + this._sourceMappingURL = options.sourceMappingURL; this._sourceMapBasepath = options.sourceMapBasepath; this._sourceMapRootpath = options.sourceMapRootpath; this._outputSourceFiles = options.outputSourceFiles; @@ -93,6 +94,7 @@ if (this._css.length > 0) { var sourceMapFilename, + sourceMappingURL, sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON()); if (this._sourceMapFilename) { @@ -105,8 +107,12 @@ sourceMapFilename = "data:application/json," + encodeURIComponent(sourceMapContent); } - if (sourceMapFilename) { - this._css.push("/*# sourceMappingURL=" + sourceMapFilename + " */"); + if (this._sourceMappingURL) { + sourceMappingURL = this.normalizeFilename(this._sourceMappingURL); + } + + if (sourceMappingURL || sourceMapFilename) { + this._css.push("/*# sourceMappingURL=" + sourceMappingURL || sourceMapFilename + " */"); } }