mirror of
https://github.com/less/less.js.git
synced 2026-01-23 06:07:56 -05:00
allow sourcemaps to be inline, in the css
This commit is contained in:
12
bin/lessc
12
bin/lessc
@@ -247,11 +247,13 @@ if (options.depends) {
|
||||
sys.print(outputbase + ": ");
|
||||
}
|
||||
|
||||
var writeSourceMap = function(output) {
|
||||
var filename = options.sourceMapFullFilename || options.sourceMap;
|
||||
ensureDirectory(filename);
|
||||
fs.writeFileSync(filename, output, 'utf8');
|
||||
};
|
||||
if (options.sourceMap !== "inline") {
|
||||
var writeSourceMap = function(output) {
|
||||
var filename = options.sourceMapFullFilename || options.sourceMap;
|
||||
ensureDirectory(filename);
|
||||
fs.writeFileSync(filename, output, 'utf8');
|
||||
};
|
||||
}
|
||||
|
||||
var parseLessFile = function (e, data) {
|
||||
if (e) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
(function (tree) {
|
||||
var sourceMap = require("source-map");
|
||||
|
||||
tree.sourceMapOutput = function (options) {
|
||||
this._css = [];
|
||||
@@ -11,6 +10,7 @@
|
||||
this._sourceMapBasepath = options.sourceMapBasepath;
|
||||
this._sourceMapRootpath = options.sourceMapRootpath;
|
||||
this._outputSourceFiles = options.outputSourceFiles;
|
||||
this._sourceMapGeneratorConstructor = options.sourceMapGenerator || require("source-map").SourceMapGenerator;
|
||||
|
||||
if (this._sourceMapRootpath && this._sourceMapRootpath.charAt(this._sourceMapRootpath.length-1) !== '/') {
|
||||
this._sourceMapRootpath += '/';
|
||||
@@ -66,7 +66,7 @@
|
||||
};
|
||||
|
||||
tree.sourceMapOutput.prototype.toCSS = function(env) {
|
||||
this._sourceMapGenerator = new sourceMap.SourceMapGenerator({ file: this._outputFilename, sourceRoot: null });
|
||||
this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null });
|
||||
|
||||
if (this._outputSourceFiles) {
|
||||
for(var filename in this._contentsMap) {
|
||||
@@ -77,10 +77,21 @@
|
||||
this._rootNode.genCSS(env, this);
|
||||
|
||||
if (this._css.length > 0) {
|
||||
this._writeSourceMap(JSON.stringify(this._sourceMapGenerator.toJSON()));
|
||||
var sourceMapFilename,
|
||||
sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON());
|
||||
|
||||
if (this._sourceMapFilename) {
|
||||
this._css.push("/*# sourceMappingURL=" + this.normalizeFilename(this._sourceMapFilename) + " */");
|
||||
sourceMapFilename = this.normalizeFilename(this._sourceMapFilename);
|
||||
}
|
||||
|
||||
if (this._writeSourceMap) {
|
||||
this._writeSourceMap(sourceMapContent);
|
||||
} else {
|
||||
sourceMapFilename = "data:application/json," + encodeURIComponent(sourceMapContent);
|
||||
}
|
||||
|
||||
if (sourceMapFilename) {
|
||||
this._css.push("/*# sourceMappingURL=" + sourceMapFilename + " */");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user