mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
get the map file outputting and reference file from the end of the css file
This commit is contained in:
15
bin/lessc
15
bin/lessc
@@ -139,7 +139,9 @@ args = args.filter(function (arg) {
|
||||
}
|
||||
break;
|
||||
case 'source-map':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
if (!match[2]) {
|
||||
options.sourceMap = true;
|
||||
} else {
|
||||
options.sourceMap = match[2];
|
||||
}
|
||||
break;
|
||||
@@ -186,6 +188,14 @@ if (output) {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.sourceMap === true) {
|
||||
if (!output) {
|
||||
sys.puts("the sourcemap option only has an optional filename if the css filename is given");
|
||||
return;
|
||||
}
|
||||
options.sourceMap = output + ".map";
|
||||
}
|
||||
|
||||
if (! input) {
|
||||
sys.puts("lessc: no input files");
|
||||
sys.puts("");
|
||||
@@ -250,7 +260,8 @@ var parseLessFile = function (e, data) {
|
||||
ieCompat: options.ieCompat,
|
||||
compress: options.compress,
|
||||
cleancss: options.cleancss,
|
||||
sourceMap: options.sourceMap,
|
||||
sourceMap: Boolean(options.sourceMap),
|
||||
sourceMapFilename: options.sourceMap,
|
||||
writeSourceMap: writeSourceMap,
|
||||
maxLineLen: options.maxLineLen,
|
||||
strictMath: options.strictMath,
|
||||
|
||||
@@ -51,7 +51,7 @@ var lessc_helper = {
|
||||
sys.puts(" that will output the information within a fake");
|
||||
sys.puts(" media query which is compatible with the SASS");
|
||||
sys.puts(" format, and 'all' which will do both.");
|
||||
sys.puts(" --source-map=FILENAME Outputs a sourcemap to the filename.");
|
||||
sys.puts(" --source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map)");
|
||||
sys.puts(" -rp, --rootpath=URL Set rootpath for url rewriting in relative imports and urls.");
|
||||
sys.puts(" Works with or without the relative-urls option.");
|
||||
sys.puts(" -ru, --relative-urls re-write relative urls to the base less file.");
|
||||
|
||||
@@ -472,7 +472,8 @@ less.Parser = function Parser(env) {
|
||||
{
|
||||
writeSourceMap: options.writeSourceMap,
|
||||
rootNode: evaldRoot,
|
||||
contentsMap: parser.imports.contents
|
||||
contentsMap: parser.imports.contents,
|
||||
sourceMapFilename: options.sourceMapFilename
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
this._rootNode = options.rootNode;
|
||||
this._writeSourceMap = options.writeSourceMap;
|
||||
this._contentsMap = options.contentsMap;
|
||||
this._sourceMapFilename = options.sourceMapFilename;
|
||||
|
||||
this._lineNumber = 0;
|
||||
this._column = 0;
|
||||
@@ -50,6 +51,10 @@
|
||||
|
||||
this._writeSourceMap(JSON.stringify(this._sourceMapGenerator.toJSON()));
|
||||
|
||||
if (this._sourceMapFilename) {
|
||||
this._css.push("/*# sourceMappingURL=" + this._sourceMapFilename + " */");
|
||||
}
|
||||
|
||||
return this._css.join('');
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ function getErrorPathReplacementFunction(dir) {
|
||||
}
|
||||
|
||||
function testSourcemap(name, err, compiledLess, doReplacements, sourcemap) {
|
||||
fs.readFile(path.join('test/sourcemaps', name) + '.json', 'utf8', function (e, expectedSourcemap) {
|
||||
fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
|
||||
sys.print("- " + name + ": ");
|
||||
if (sourcemap === expectedSourcemap) {
|
||||
ok('OK');
|
||||
|
||||
Reference in New Issue
Block a user