Skip to content

Instantly share code, notes, and snippets.

@kunkun12
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunkun12/31fb79a11e4cfd521b8e to your computer and use it in GitHub Desktop.
Save kunkun12/31fb79a11e4cfd521b8e to your computer and use it in GitHub Desktop.
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