繁体   English   中英

GruntJS livereload对我不起作用

[英]GruntJS livereload is not working for me

我正在尝试配置启用了livereload选项的grunt-contrib-watch。 我正在将Ubuntu 13.04与Firefox 26.0 / Chrome结合使用

这是我的Gruntfile.js

module.exports = function(grunt) {
    grunt.initConfig({   
        watch: {
            options: {
                livereload: true
            },
            html: {
                files: ['*.php', '*.html'],
            }
        }
    });

    grunt.event.on('watch', function(action, filepath, target) {
        grunt.log.writeln(target + ': ' +  filepath + ' has ' + action);
    });

    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', ['watch']);
};

这是index.html

<html>
    <head>
        <title>Grunt, Gruntfile.js</title>
    </head>

    <body>
        <h1>It works!</h1>
        <p>This is the default web page for this server.</p>
        <p>The web server software is running but no content has been added, yet.</p>

        <script src="//localhost:35729/example/livereload.js"></script>
    </body>
</html>

我通过在终端启动grunt手表并在localhost / example / index.html上打开浏览器进行了测试,我已经尝试了Firefox和Chrome。

尝试编辑index.html文件后,我注意到文件“ index.html”已更改。 在运行了grunt watch的终端上,但根本没有在浏览器上自动重新加载。

我还安装了Firefox和Chrome LiveReload扩展程序,但也无法正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM