Grunt警告:任务“默认”未找到

时间:2014-04-09 21:17:09

标签: gruntjs

我正在尝试使用Grunt,我正在接受警告:任务"默认"我尝试运行Grunt时找不到错误。我的Gruntfile.js是

module.exports = function(grunt) {

grunt.initConfig({
concat: {
  js: {
    options: {
      separator: ';'
    },
    src: [
      'library/js/*.js'
    ],
    dest: 'library/js/scripts.min.js'
  },
},

uglify: {
  options: {
    mangle: false
  },
  js: {
    files: {
      'library/js/scripts.min.js': ['library/js/scripts.min.js']
    }
  }
},

less: {
  style: {
    files: {
      "library/css/style.css": "library/less/style.less"
    },
  }
},

watch: {
  js: {
    files: ['library/js/*.js'],
    tasks: ['concat:js', 'uglify:js'],
    options: {
        livereload: 35729
    }
  },
  css: {
    files: ['library/less/*.less'],
    tasks: ['less:style'],
    options {
        livereload: 35729
    }
  },
  php : {
    files : ['**/*.php'],
    options : {
      livereload : 35729
      } 
  }
}
  });



grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.registerTask('default', ['watch']);
};

这一直有效,直到我添加了Livereload部分,我认为这可能是语法错误。然而,这是我第一次使用它,而我根本不知道导致问题的原因。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:7)

您错过了watch.css.options的冒号。更新至:

css: {
    files: ['library/less/*.less'],
    tasks: ['less:style'],
    options: {
        livereload: 35729
    }
}

答案 1 :(得分:1)

如果以后有人发现这是为了让livereload工作,我必须将手表部分更改为

watch: {
  js: {
    files: ['library/js/*.js'],
    tasks: ['concat:js', 'uglify:js'],
  },
  css: {
    files: ['library/less/*.less'],
    tasks: ['less:style'],
  },
  php : {
    files: ['**/*.php'],
  },
  options: {
      livereload: true,
      spawn: false
  }
}