Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No page refresh but all else works #95

Open
iDVB opened this issue Aug 5, 2015 · 3 comments
Open

No page refresh but all else works #95

iDVB opened this issue Aug 5, 2015 · 3 comments

Comments

@iDVB
Copy link

iDVB commented Aug 5, 2015

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'
        }
      }
    },
@iDVB
Copy link
Author

iDVB commented Aug 5, 2015

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.

@kamalsomani
Copy link

I am facing the same issue, any solution ?

@danidev
Copy link

danidev commented Jun 15, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants