1

这是我的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']);
};

在此处输入图像描述

在此处输入图像描述

4

1 回答 1

2

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

return [
    function(req, res, next) {
        res.setHeader('X-UA-Compatible', 'IE-edge');
        next();
     },
     connect.static('project')
]
于 2016-02-09T19:31:12.173 回答