我使用以下内容:
var path = require('path');
module.exports = function(grunt) {
grunt.initConfig({
less: {
options: {
paths: '/',
yuicompress: false,
ieCompat: true,
compress: false,
sourceMap: true,
sourceMapFilename: 'alice/public/local/less/intfarm.css.map',
require: [
'alice/public/local/less/intfarm.less'
]
},
src: {
expand: true,
src: ['alice/public/local/less/*.less'],
ext: '.css',
dest: 'alice/public/local/css/local/compiled/',
}
},
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.registerTask('default', ['less']);
}
我不明白为什么'src'路径也为'dest'路径生成..:
/alice/public/local/css/local/compiled/alice/public/local/less/account.css
我在期待:
/alice/public/local/css/local/compiled/account.css
答案 0 :(得分:0)
这是因为您没有使用cwd
选项。 src
选项包含matching patterns,它解析为相对于cwd路径的路径。简单来说,src
中匹配的所有文件路径都位于dest
结果中。
所以你需要以下配置来解决你的问题。
src: {
expand: true,
cwd: 'alice/public/local/less/',
src: ['*.less'],
ext: '.css',
dest: 'alice/public/local/css/local/compiled/',
}