grunt-contrib-less不工作(没有错误但没有输出css)

时间:2014-12-09 09:39:27

标签: gruntjs grunt-contrib-less

我有一个较少编译的grunt任务,其中来自grunt安装文件夹的较少文件的相对路径为raw/less/source_map/

这是grunt文件。

Gruntfile :( 编辑:改为@Yogesh Khatri的代码仍然是同样的问题)

module.exports = function(grunt) {
    grunt.initConfig({
        less: {
            files: { "raw/less/source_map/style.css" : "raw/less/source_map/style.less" }
        },
        watch: {
            js: {
                files: ['raw/less/source_map/style.less'],
                    tasks: ['default'],
                }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.registerTask('default', ['less']);
};
运行它时

命令行显示

^CMacPro:grunt sagiavinashvarma$ grunt watch
Running "watch" task
Waiting...
>> File "raw/less/source_map/style.less" changed.
Running "less:files" (less) task

Done, without errors.
Completed in 1.862s at Tue Dec 09 2014 15:03:37 GMT+0530 (IST) - Waiting...

但没有style.css输出。我编写了最简单的grunt任务,没有任何选项。 任何人都可以指出这是错误的。

1 个答案:

答案 0 :(得分:2)

修改 我遇到了问题。它不起作用,因为较少的任务需要特定的目标才能工作 尝试更改像这样的代码

module.exports = function(grunt) {
    grunt.initConfig({
        less: {
          development: {
            files: { "raw/less/source_map/style.css" : "raw/less/source_map/style.less" }
          }
        },
        watch: {
            js: {
                files: ['raw/less/source_map/style.less'],
                    tasks: ['default'],
                }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.registerTask('default', ['less']);
};

我通过运行grunt --verbose得到了错误,显示了有关任务的更多信息。它给了我像

这样的输出
Verifying property less.files exists in config...OK
File: [no files]
Options: report="min", banner=""
>> Destination not written because no source files were provided.

其中搜索引导我: - grunt-contrib-less cannot find source files even though path is correct