3

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

这是咕噜声文件。

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 任务,没有任何选项。谁能指出这有什么问题。

4

1 回答 1

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 也找不到源文件

于 2014-12-09T09:49:55.047 回答