警告:找不到任务 "default"
Warning: Task "default" not found
这是我的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']);
};
你忘了在 return 数组中写逗号
return [
function(req, res, next) {
res.setHeader('X-UA-Compatible', 'IE-edge');
next();
},
connect.static('project')
]
这是我的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']);
};
你忘了在 return 数组中写逗号
return [
function(req, res, next) {
res.setHeader('X-UA-Compatible', 'IE-edge');
next();
},
connect.static('project')
]