【问题标题】:grunt-contrib-less not working (no errors but no output css)grunt-contrib-less 不工作(没有错误但没有输出 css)
【发布时间】:2015-02-07 03:38:04
【问题描述】:

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

这里是 grunt 文件。

Gruntfile: (EDIT: 改成@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 任务,没有任何选项。 谁能指出这有什么问题。

【问题讨论】:

    标签: gruntjs grunt-contrib-less


    【解决方案1】:

    编辑: 我有问题。它不起作用,因为更少的任务需要特定的目标来工作。
    尝试像这样更改代码

    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

    【讨论】:

    • 糟糕,我更改了代码。仍然没有输出。没有错误
    猜你喜欢
    • 1970-01-01
    • 2014-09-16
    • 2015-10-18
    • 2014-02-09
    • 1970-01-01
    • 1970-01-01
    • 2016-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多