[Pkg-javascript-commits] [less.js] 01/09: refactor sourcemap classes slightly for better usage by clean-css plugin sourcemaps branch

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:25:48 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v2.1.1
in repository less.js.

commit 7d970272224786c41f0c41759024641136c20d98
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sun Nov 23 13:27:42 2014 +0000

    refactor sourcemap classes slightly for better usage by clean-css plugin sourcemaps branch
---
 lib/less/index.js              |  2 +-
 lib/less/source-map-builder.js | 17 +++++++++++++++--
 lib/less/source-map-output.js  | 11 +----------
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/lib/less/index.js b/lib/less/index.js
index df1baab..e7aba3a 100644
--- a/lib/less/index.js
+++ b/lib/less/index.js
@@ -13,7 +13,7 @@ module.exports = function(environment, fileManagers) {
         functions: require('./functions')(environment),
         contexts: require("./contexts"),
         SourceMapOutput: (SourceMapOutput = require('./source-map-output')(environment)),
-        SourceMapBuilder: (SourceMapBuilder = require('./source-map-builder')(SourceMapOutput)),
+        SourceMapBuilder: (SourceMapBuilder = require('./source-map-builder')(SourceMapOutput, environment)),
         ParseTree: (ParseTree = require('./parse-tree')(SourceMapBuilder)),
         ImportManager: (ImportManager = require('./import-manager')(environment)),
         render: require("./render")(environment, ParseTree, ImportManager),
diff --git a/lib/less/source-map-builder.js b/lib/less/source-map-builder.js
index f212d11..c231fef 100644
--- a/lib/less/source-map-builder.js
+++ b/lib/less/source-map-builder.js
@@ -1,4 +1,4 @@
-module.exports = function (SourceMapOutput) {
+module.exports = function (SourceMapOutput, environment) {
 
     var SourceMapBuilder = function (options) {
         this.options = options;
@@ -26,13 +26,26 @@ module.exports = function (SourceMapOutput) {
         if (this.options.sourceMapInputFilename) {
             this.sourceMapInputFilename = sourceMapOutput.normalizeFilename(this.options.sourceMapInputFilename);
         }
-        return css;
+        return css + this.getCSSAppendage();
+    };
+
+    SourceMapBuilder.prototype.getCSSAppendage = function() {
+        var sourceMapURL = this.sourceMapURL;
+        if (this.options.sourceMapFileInline) {
+            sourceMapURL = "data:application/json;base64," + environment.encodeBase64(this.sourceMap);
+        }
+
+        if (sourceMapURL) {
+            return "/*# sourceMappingURL=" + sourceMapURL + " */";
+        }
+        return "";
     };
 
     SourceMapBuilder.prototype.getExternalSourceMap = function() {
         return this.sourceMap;
     };
     SourceMapBuilder.prototype.setExternalSourceMap = function(sourceMap) {
+        console.log(sourceMap);
         this.sourceMap = sourceMap;
     };
 
diff --git a/lib/less/source-map-output.js b/lib/less/source-map-output.js
index 0d501e5..c206f9f 100644
--- a/lib/less/source-map-output.js
+++ b/lib/less/source-map-output.js
@@ -23,7 +23,6 @@ module.exports = function (environment) {
         }
         this._outputSourceFiles = options.outputSourceFiles;
         this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator();
-        this._sourceMapFileInline = options.sourceMapFileInline;
 
         this._lineNumber = 0;
         this._column = 0;
@@ -130,15 +129,7 @@ module.exports = function (environment) {
             }
             this.sourceMapURL = sourceMapURL;
 
-            if (!this._sourceMapFileInline) {
-                this.sourceMap = sourceMapContent;
-            } else {
-                sourceMapURL = "data:application/json;base64," + environment.encodeBase64(sourceMapContent);
-            }
-
-            if (sourceMapURL) {
-                this._css.push("/*# sourceMappingURL=" + sourceMapURL + " */");
-            }
+            this.sourceMap = sourceMapContent;
         }
 
         return this._css.join('');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list