警告:找不到任务“默认”

时间:2016-02-09 19:21:50

标签: angularjs gruntjs gruntfile

这是我的Gruntfile.js

module.exports = function(grunt) {
  require('logfile-grunt')(grunt, {
    filePath: './logs/grunt.log',
    clearlogFile: true
  });
  grunt.initConfig({
    // pkg: grunt.file.readJSON('package.json'),
    connect: {
      server: {
        options: {
          port: 9001,
          hostname: '*',
          middleware: function(connect, options) {
            return [
              function(req, res, next) {
                res.setHeader('X-UA-Compatible', 'IE-edge');
                next();
              }
              connect.static('project')
            ]
          }
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      files: ['project/**/*.js', 'project/**/*.html', 'project/**/*.css'],
      task: []
    }
  });

  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['connect:server', 'watch']);
};

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:2)

你忘了在返回数组中写昏迷

return [
    function(req, res, next) {
        res.setHeader('X-UA-Compatible', 'IE-edge');
        next();
     },
     connect.static('project')
]