【发布时间】:2014-05-30 03:46:07
【问题描述】:
我正在使用 Grunt (grunt-contrib-less) 将我的 Less 文件处理成 CSS。这是可行的,但源地图不行。
我的 Less 文件在 /assets/less 中,Grunt 将它们编译成 /public/css。
/public/ 是我的文件夹,可在 Internet 上公开查看。我想有一种方法可以让 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
},
]
【问题讨论】:
标签: css less gruntjs source-maps grunt-contrib-less