我有这样的Grunt文件:
module.exports = function(grunt){
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
dev: {
options: {
port: 8999,
livereload: 35729,
hostname: 'localhost'
},
livereload: {
options: {
open: {
target: 'http://localhost:8999'
},
base: [
'src/main'
]
}
}
}
},
open: {
dev: {
path: 'http://localhost:<%= connect.dev.options.port %>'
}
}
});
grunt.registerTask('default', ['connect:dev', 'open:dev']);
}
但是我的问题是,只要打开浏览器,服务器就会在此之前停止。
请帮忙。提前致谢。
您可以添加一个监视任务,该任务将监视更改的文件并使服务器保持运行状态:
watch: {
options: {
nospawn: true
},
livereload: {
options: {
livereload: LIVERELOAD_PORT
},
files: [
'src/main/*.js',
'src/main/*.html'
]
}
},
然后将任务更改为:
grunt.registerTask('default', ['connect:dev', 'open:dev', 'watch']);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句