减少任务找不到错误

时间:2016-01-27 23:35:04

标签: javascript node.js twitter-bootstrap gruntjs

我最近开始使用grunt并且似乎无法正常工作:我使用npm安装了grunt-cli,并且使用npm安装了一些grunt模块,没有任何问题。我试图将所有引导程序框架中较少的文件编译成一个css文件,但不断收到错误,说找不到更少的任务。我确定一切都在它应该是的地方,我在gruntfile中加载了grunt-contrib-less插件。知道我可能会出错吗?

我的package.json的内容:

{
    "name": "dConference",
    "version": "0.1.0",
    "devDependencies": {
    "grunt": "latest",
    "grunt-contrib-jshint": "latest",
    "jshint-stylish": "latest",
    "grunt-contrib-uglify": "latest",
    "grunt-contrib-less": "latest",
    "grunt-contrib-cssmin": "latest",
    "grunt-contrib-watch": "latest" 
    }
}

我的gruntfile.js的内容:

//gruntfile specifying all tasks to be performed

module.exports = function(grunt){
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        //all configuration goes here
        less: {
            build: {
                files: [{
                    expand: true,
                    cwd: "components/less",
                    src: ["*.less"]
                    dest: "css/main.css"
                }               ]
            }
        }

    });

    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks("grunt-contrib-cssmin");
    grunt.loadNpmTasks("grunt-contrib-watch");



};

1 个答案:

答案 0 :(得分:1)

我将Gruntfile.js作为以下内容。

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        less: {
            build: {
                files: {
                    'css/main.css': 'components/less/bootstrap.less'
                }
            }
        }

    });

    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks("grunt-contrib-cssmin");
    grunt.loadNpmTasks("grunt-contrib-watch");
};

跑步"咕噜咕噜"在项目根文件夹上成功。 成功运行" grunt less"命令,main.css是在css文件夹下生成的。

项目结构是:

咕噜测试项目

  • 组件/更少
    • mixins文件夹
    • 所有其他bootstrap less files
  • CSS
  • Gruntfile.js
  • 的package.json

请尝试一下,让我知道结果。