我重新阅读了grunt watch页面上的指南,并在其他地方遵循了3个不同的示例,但当html或js文件被修改时,我无法让它自动刷新我的页面……我的意思是,我收到了"File changed: views/entryw.html“消息,所以正在监视它,但没有自动重新加载/自动刷新的迹象
我的服务器在9000端口上运行
这是我的Gruntfile.js的样子:
module.exports = function (grunt) {
// --------------------------------------------------------------------------------------------- //
// Configuration
// --------------------------------------------------------------------------------------------- //
grunt.initConfig({
browserSync: {
bsFiles: {
src : [
'forbiddenDirectory/*.js',
'views/*.html'
]
},
/*options: {
server: {
baseDir: "./"
}
}*/
options: {
proxy: "localhost:3000",
open: false
}
}
});
// --------------------------------------------------------------------------------------------- //
// Load plugins
// --------------------------------------------------------------------------------------------- //
grunt.loadNpmTasks('grunt-browser-sync');
// --------------------------------------------------------------------------------------------- //
// register tasks
// --------------------------------------------------------------------------------------------- //
grunt.registerTask('default', ['browserSync']);
//grunt.registerTask('all', ['default']) // each index in array is the name of registered tasks above
}发布于 2017-01-23 01:26:53
我认为proxy option应该指向端口9000上的服务器,如下所示:
options: {
proxy: 'http://localhost:9000'
}然后,您可以通过http://localhost:3000上的浏览器同步来访问您的应用程序,这将通过代理为端口9000上的实际服务器提供服务。
YMMV,因为您的服务器可能需要重新启动才能使更改生效。
https://stackoverflow.com/questions/41793759
复制相似问题