Eva*_*olo 13 javascript gruntjs
我无法让LiveReload与Grunt合作.我正在使用grunt-contrib-watch.当Grunt正在观看所述文件时,浏览器中没有任何内容正在重新加载.所以我会看到:
Running "watch" task
Completed in 0.203s at Thu Nov 21 2013 00:59:59 GMT-0500 (EST) - Waiting...
OK
>> File "views/index.html" changed.
Run Code Online (Sandbox Code Playgroud)
但浏览器窗口不会更新.我正在使用LiveReload 2.0.9.关于如何让它运行的任何建议?
Gruntfile.js
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
express: {
dev: {
options: {
script: './app.js'
}
}
},
watch: {
tasks: [ 'express:dev' ],
options: {
livereload: true,
nospawn: true
},
files: [
'./views/index.html',
'./preprocessing/css/style.scss'
]
}
});
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [ 'express:dev', 'watch' ]);
};
Run Code Online (Sandbox Code Playgroud)
And*_*ion 20
它看起来你所缺少的是在文档中包含livereload脚本:<script src="//localhost:35729/livereload.js"></script>
默认情况下.
如果要避免必须手动执行此操作,可以使用connect-livereload中间件.
这是一个示例Gruntfile.js,它使用我链接的中间件进行观看和实时重载.
归档时间: |
|
查看次数: |
17610 次 |
最近记录: |