我正在使用 Grunt (grunt-contrib-less) 将我的 Less 文件处理成 CSS。这是有效的,但源映射不是。
我的 Less 文件位于 .Grunt 中/assets/less
,Grunt 将它们编译成/public/css
.
/public/
是我在互联网上公开查看的文件夹。我想有一种方法可以让 sourcemaps 工作,即使我的源 Less 文件不在可公开访问的文件夹中。但是我没有找到任何例子。
我的 grunt-contrib-less 配置是:
options: {
compress: true,
yuicompress: true,
optimization: 2,
sourceMap: true,
sourceMapFilename: "public/css/main.css.map", //Write the source map to a separate file with the given filename.
sourceMapBasepath: "../assets/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: [
{
expand: true, // Enable dynamic expansion.
cwd: 'assets/less/', // Src matches are relative to this path.
src: ['*.less'], // Actual pattern(s) to match.
dest: 'public/css/', // Destination path prefix.
ext: '.css', // Dest filepaths will have this extension.
extDot: 'first' // Extensions in filenames begin after the first dot
},
]