0

I am currently using Grunt and livereload, but for some reason in the last while it no longer does a full server restart when server files are changed. It is watching the server files and I get a Reload server/some_dir/some_file.js message when a file changes but that doesn't seem to be enough.

watch: {
  jade: {
    files: [
      '<%= yeoman.server %>/**/*.jade',
      '<%= yeoman.app %>/**/*.jade'
    ],
    tasks: ['jade']
  },
  compass: {
    files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
    tasks: ['compass']
  },
  livereload: {
    options: { livereload: true },
    files: [
      '{.tmp,<%= yeoman.server %>}/**/*.js',
      '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
      '{.tmp,<%= yeoman.app %>}/scripts/**/*.js',
      '{.tmp,<%= yeoman.app %>}/**/*.html',
      '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
    ],
    tasks: ['livereload']
  },
  server: {
    files:  [ './server/**/*' ],
    tasks:  [ 'express:dev', 'livereload-start' ]
  }
}

grunt.registerTask('server', [
  'clean:server',
  'jade',
  'compass:server',
  'express:dev',
  'livereload-start',
  'connect:livereload',  
  'watch'  // if I replace this with 'watch:server' the server does restart properly, but html/css updates are obviously gone
]);
chris
  • 4,332
  • 5
  • 41
  • 61

2 Answers2

1

I'm not sure what version of these packages you're using but livereload is no longer (and hasn't been for a few months) a task in and of itself. It should now be run as an option of watch https://github.com/gruntjs/grunt-contrib-watch#optionslivereload.

Here's an example:

watch: {
    assets: {
        files: ['assets/**/*'],
        tasks: ['copy:assets']
    },
    scripts: {
        files: ['scripts/source/*.js'],
        options: {
            livereload: true
        }
    }
}

grunt.registerTask('default', ['watch']);
imjared
  • 19,492
  • 4
  • 49
  • 72
  • Unfortunately, I seem to be tied back to using the old grunt-contrib-livereload gem since the livereload chrome extension throws up when using grunt-contrib-watch. – chris Oct 18 '13 at 16:48
  • The real problem is not so much livereload, but rather that the server is not fully restarting on server file changes. – chris Oct 18 '13 at 16:53
0

Changing

server: {
  files:  [ './server/**/*' ],
  tasks:  [ 'express:dev', 'livereload-start' ]
}

to

server: {
  files:  [ './server/**/*' ],
  tasks:  [ 'express:dev', 'livereload' ]
}

Not sure what recent change caused this to break. According to git the former snippet was used since the start of the project.

chris
  • 4,332
  • 5
  • 41
  • 61