我正在尝试使用grunt-contrib-watch和grunt-contrib-compass使grunt工作。
到目前为止,我的Gruntfile看起来像这样:
module.exports = function (grunt){
grunt.initConfig({
compass : {
dist : {
options : {
debugInfo : 'true'
}
}
},
watch : {
files : ['*.html', 'js/*', 'sass/*'],
task : ['compass'],
options : {
livereload: true,
port : 35729
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch') ;
grunt.loadNpmTasks('grunt-contrib-compass') ;
grunt.registerTask('default', ['watch'])
} ;
我正在使用chromes live-reload扩展程序。
如果然后运行'grunt -v',我可以看到grunt按预期监视了我的html和sass文件。我的浏览器选项卡会按预期自动重新加载。
在浏览器标签中,我转到以下地址:
http://localhost:35729
但是,在我的浏览器中,只有在加载和重新加载后才能看到此信息:
{
tinylr: "Welcome",
version: "0.0.4"
}
我没有看到index.html。只是对象。
我需要做什么才能看到我的网站?
http://localhost:35729
是实时重新加载服务器的地址,而不是您的网站。您的网站仍然需要通过其自己的地址/端口进行访问,例如http://localhost:8000
。通过grunt-contrib-connect任务,其他一些node.js服务器或提供文件apache / nginx的服务器。
http://localhost:35729
仅用于将实时重新加载脚本加载到您的页面中:<script src="http://localhost:35729/livereload.js"></script>
然后在更改后将使用Web套接字触发并更新您网站上的页面。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句