简体   繁体   中英

Grunt Warning: Task “default” Not Found

I am experimenting with Grunt and I am getting a Warning: Task "default" not found error when I try to run Grunt. my Gruntfile.js is

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']);
};

This was working until I added the Livereload portions, and I think it might be a syntax error. However this is the first time I have used this and I simply don't know what is causing the problem. Any help would be greatly appreciated.

You're missing a colon for watch.css.options . Update to:

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

In case anyone finds this later to get livereload to work I had to change the watch section to

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
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM