【发布时间】:2014-11-05 21:36:51
【问题描述】:
我有多个 .less 文件,我想将它们处理为匹配的 .css 和 sourceMaps,每个文件都在与源相同的文件夹中。
这有多难?
我直接用 less 执行此操作没有问题,但无法弄清楚如何在 grunt-contrib-less 中执行此操作,因为它似乎希望 sourceMapFilename 是单个硬编码值。
这是我的 gruntfile:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
watch: {
options: {
livereload: true,
},
css: {
files: ['./core/theme/**/*.less'],
tasks: ['less'],
options: {
spawn: false
},
},
},
less: {
all: {
src: ['./core/theme/**/*.less'],
expand: true,
dest: "./core/theme/",
options:{sourceMap:true},
rename:function (dest, src) {
return src.substring(0, src.lastIndexOf('.'))+'.css';
}
},
}
});
// on watch events configure less:all to only run on changed file
grunt.event.on('watch', function(action, filepath) {
grunt.config('less.all.src', filepath);
});
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-less");
grunt.registerTask("default", ["less"]);
};
TIA
【问题讨论】:
标签: less gruntjs source-maps