Instantly share code, notes, and snippets.

Embed
What would you like to do?
grunt-live-reload config
module.exports = function(grunt){
require('load-grunt-tasks')(grunt); //加载所有的任务
grunt.initConfig({
connect: {
options: {
port: 80,
hostname: 'localhost', //默认就是这个值,可配置为本机某个 IP,localhost 或域名
livereload: 35729 //声明给 watch 监听的端口
},
server: {
options: {
open: true, //自动打开网页 http://
base: [
'../work' //主目录
]
}
}
},
watch: {
livereload: {
options: {
livereload: '<%=connect.options.livereload%>' //监听前面声明的端口 35729
},
files: []//下面文件的改变就会实时刷新网页
}
}
});
grunt.registerTask('serve', [
'connect:server',
'watch'
]);
}
{
"name": "test_connect",
"version": "0.0.1",
"devDependencies": {
"grunt-contrib-connect": "*",
"grunt-contrib-watch": "*",
"load-grunt-tasks": "*"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment