我正在使用grunt 0.4.2和grunt-contrib-less 0.9.0。 我希望将LESS编译成支持源映射的CSS。
我的LESS文件位于public/less
中,主文件名为main.less
。
public/less/main.less
编译成public/css/main.css
可以工作,但源映射不起作用。
以下是我的Grunt配置有什么问题?
{
less: {
dev: {
options: {
compress: true,
yuicompress: true,
optimization: 2,
sourceMap: true,
sourceMapFilename: "public/css/main.css.source-map.json", //Write the source map to a separate file with the given filename.
sourceMapBasepath: "public/less", //Sets the base path for the Less file paths in the source map.
sourceMapRootpath: "/"//Adds this path onto the Less file paths in the source map.
},
files: {
"public/css/main.css": "public/less/main.less"
}
}
},
watch: {
styles: {
files: ["public/less/*"],
tasks: ['less'],
options: {
livereload: true,
nospaces: true
}
}
}
}
我不想让我的CSS创建在/public/less
文件夹中; 我想将它放到/public/css
文件夹下。否则,我可以使用另一个有效的配置:
{
less: {
dev: {
options: {
compress: true,
yuicompress: true,
optimization: 2,
sourceMap: true,
sourceMapFilename: "public/less/main.css.map", //I DO NOT WANT THE CSS MAP HERE
sourceMapBasepath: "public/less", //Sets the base path for the Less file paths in the source map.
},
files: {
"public/less/main.css": "public/less/main.less"//I DO NOT WANT THE CSS HERE
}
}
},
watch: {
styles: {
files: ["public/less/*"],
tasks: ['less'],
options: {
livereload: true,
nospaces: true
}
}
}
}
sourceMapURL
行,因为它似乎是不必要的。 - Ryan