gruntjs / grunt-contrib-watch

Run tasks whenever watched files change.
http://gruntjs.com/
MIT License
1.98k stars 356 forks source link

No reload with images #269

Open hunterwebsiteservices opened 10 years ago

hunterwebsiteservices commented 10 years ago

For the life of me I cannot get changes to image files to trigger a reload.

I have successfully gotten things to work with changes with js and less/css files. It reloads just the CSS when it is changed and reloads the whole page as desired on PHP/Javascript changes.

Grunt watch task looks like

        watch: {
            less: { 
                files: '<%= myVars.paths.themeSkin %>less/*.less',
                tasks: ['less:theme']
            },
            js: { 
                files: '<%= myVars.paths.themeSkin %>**/*.js',
                tasks: ['jshint:theme', 'concat:theme', 'uglify:theme']
            },
            reloadLess: {
                files: '<%= myVars.paths.themeSkin %>compiled/stylesheet.css',
                options: {
                    livereload: true
                }
            },
            reloadJs: {
                files: '<%= myVars.paths.themeSkin %>compiled/javascript.js',
                options: {
                    livereload: true
                }
            },
            reloadImgs: {
                files: '<%= myVars.paths.themeSkin %>images/**/*',
                options: {
                    livereload: true
                }
            },
            php: {
                files: ['**/*.php', '**/*.phtml'],
                options: {
                    livereload: true
                }
            },
            gruntfile: {
                files: '<%= jshint.gruntfile.src %>',
                tasks: ['jshint:gruntfile']
            }
        }
    });

I am using Chrome with the LiveReload plugin at http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions- and getting the following message in Chrome DevTools (similar story with Firefox and when using the SCRIPT tag implementation).

Request URL:ws://127.0.0.1:35729/livereload
Request Method:GET
Status Code:101 Switching Protocols
Request Headersview source
Cache-Control:no-cache
Connection:Upgrade
Host:127.0.0.1:35729
Origin:http://removed
Pragma:no-cache
Sec-WebSocket-Extensions:x-webkit-deflate-frame
Sec-WebSocket-Key:EiPD4Y98r0ND0PIt8Djo1w==
Sec-WebSocket-Version:13
Upgrade:websocket
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Response Headersview source
Connection:Upgrade
Sec-WebSocket-Accept:Q5oz7kX6jr5sVJZRiKlqayYW9Ss=
Upgrade:websocket

So Chrome is detecting a change, but something is failing. This looks distinctly different to a successful reload of CSS which is accessing: http://domain.com/path/compiled/stylesheet.css?livereload=1389067307681 and not failing at ws://127.0.0.1:35729/livereload

sshmyg commented 10 years ago

MacOS - watch work (but delete image folders NOT) Windows - NOPE (((