ericclemmons / grunt-express-server

Grunt task for running an Express Server that works great with LiveReload + Watch/Regarde

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No page refresh but all else works

iDVB opened this issue · comments

Watch detects changes and restarts express server.... but the browser never refreshes to see those changes.

Usually you have to inject livereload client into the html pages for this to work. However, I've not been able to find any details on how to do this with this module.

What am I doing wrong?

    watch: { // grunt-contrib-watch
      options: {
        livereload: true
      },
      express: {
        files:  [ '<%= project.path.server %>/**/*.js' ],
        tasks:  [ 'express:dev' ],
        options: {
          spawn: false, // for grunt-contrib-watch v0.5.0+, "nospawn: true" for lower versions. Without this option specified express won't be reloaded
          livereload: true
        }
      },      
      browserify: {
        files: [
          '<%= project.path.client %>/js/**/*.{jsx,js}'
        ],
        tasks: ['browserify:dist']
      },
      sass: {
        files: ['<%= project.path.client %>/sass/**/*.{css,scss}'],
        tasks: ['sass:dist']
      },
      html: {
        files: ['<%= project.path.client %>/**/*.html'],
        tasks: ['copy:dist']
      },
    },

    express: { // grunt-express-server
      dev: {
        options: {
          script: '<%= project.path.server %>/app.js'
        }
      },
      prod: {
        options: {
          script: '<%= project.path.server %>/app.js',
          node_env: 'production'
        }
      }
    },

So the docs really read with no mention of livereload.js or the need for a browser plugin, so I'm still thinking there is a way to do this without.

However, I got it to work simply by adding the following to the html.

    <script>
      // LiveReload Updates: Need to find a way to remove this for production
      document.write('<script src="http://'
      + (location.host || 'localhost').split(':')[0]
      + ':35729/livereload.js?snipver=1"></'
      + 'script>')
    </script>

Please let me know if this is required or if there is a better way.

I am facing the same issue, any solution ?

same problem here. does anyone know or could be so kind to answer?
Thanks in advance,
Daniele