【发布时间】:2014-07-16 13:37:06
【问题描述】:
在这里完全是 Grunt 的新手,但基本上我正在尝试使用 Grunt 来做一些事情。缩小一个JS文件,将多个LESS文件编译成一个CSS文件。
javascript 位有效,即我的文件 custom.js 压缩为一个名为 custom.min.js 的文件,但是 LESS 位根本不起作用(没有错误,只是无法编译)。谁能看出这是为什么?
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
build: {
src: 'scripts/custom.js',
dest: 'scripts/custom.min.js'
}
},
less: {
build: {
src: 'less/*.less',
dest: 'style.css'
}
},
watch: {
files: ['scripts/custom.js'],
tasks: ['uglify','less']
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
// Default task(s).
grunt.registerTask('default', ['uglify']);
};
【问题讨论】:
-
你在运行命令
grunt less吗? -
我正在运行
grunt watch,它应该同时运行这两个任务。问题在于目前的任务较少,因为 JS 任务运行完美
标签: javascript css node.js gruntjs less