1

我正在做的项目是使用代码来运行 less 编译器。

我无法从我的 less 文件中将内联源映射添加到已编译的 css。从节点我们正在运行以下代码:

var less = require('less'),
    options = {
        strictMath: true
    };

less.render(data, options, function(err, css) {
    callback(err, css);
});

有没有我可以添加的选项?我试过添加sourceMap: trueoutputSourceFiles: true没有成功。

4

1 回答 1

0

从 Less v 1.5 开始,编译器支持以下选项

  --source-map[=FILENAME]  Outputs a v3 sourcemap to the filename (or output filename.map)
  --source-map-rootpath=X  adds this path onto the sourcemap filename and less file paths
  --source-map-basepath=X  Sets sourcemap base path, defaults to current working directory.
  --source-map-less-inline puts the less files into the map instead of referencing them
  --source-map-map-inline  puts the map (and any less files) into the output css file
  --source-map-url=URL     the complete url and filename put in the less file

您尝试过的sourceMapandoutputSourceFiles选项似乎与 grunt-contrib-less 有关,请参阅:https ://github.com/gruntjs/grunt-contrib-less

于 2014-10-05T09:48:19.220 回答