这是我的 Gruntfile.js: /*全局模块 */
module.exports = function(grunt) {
'use strict';
// Load Grunt tasks declared in the package.json file
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
connect: {
all: {
options:{
port: 9000,
hostname: '0.0.0.0',
base: 'app',
keepalive: true,
livereload: true
}
}
},
less: {
development: {
files: {
'app/css/easier.css': 'app/less/easier.less'
}
}
},
watch: {
less: {
files: ['app/less/easier.less'],
tasks: ['less']
},
scripts: {
files: ['app/**/*.js'],
options: {
spawn: false,
livereload: true
}
}
}
});
grunt.registerTask('server',[
'connect',
'watch'
]);
};
我运行该grunt server命令,然后我的文件就按应有的方式提供了服务。在我运行的另一个控制台中grunt watch,如果有任何更改,它会在浏览器中自动更改。是什么让这一切只用命令来完成grunt server。我认为通过watch在服务器任务中添加任务可以解决这个问题,但它不起作用。我尝试livereload仅通过任务在 Chrome中启用,但watch我收到一条警报,提示Could not connect to LiveReload server. Please make sure that LiveReload 2.3 (or later) or another compatible server is running. 我错过了什么?