grunt-contrib-connect从0.11.x版本开始不支持
connect.static和
connect.directory
你应该安装serve-static(加载静态文件)和
serve-index(加载目录)
npm install --save-dev grunt-contrib-connect serve-static
使用例子
var serveStatic = require('serve-static');
var serveIndex = require('serve-index');
grunt.initConfig({
connect: {
options: {
test: {
directory: 'somePath',
middleware: function(connect, options){
var _staticPath = path.resolve(options.directory);
return [serveStatic(_staticPath), serveIndex(_staticPath)]
}
}
}
}
})
参考链接http://*.com/questions/32961124/warning-connect-static-is-not-a-function-use-force-to-continue