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

livereload option doesn't insert livereload script #60

Open
azhang opened this issue May 13, 2014 · 2 comments
Open

livereload option doesn't insert livereload script #60

azhang opened this issue May 13, 2014 · 2 comments

Comments

@azhang
Copy link

azhang commented May 13, 2014

My grunt express settings:

express: {
  options: {
    port: 3000
  },
  livereload: {
    options: {
      livereload: true,
      bases: "build",
      server: path.resolve('server/grunt-index.js'),
      showStack: true,
      middleware: [
        function myMiddleware(req, res, next) {
          console.log("here");
        }
      ]
    }
  }
},

I'm using the example under "if you want to use both express and socket.io". I added a console.log to see which middleware is loaded.

exports.use = function() {
  console.log(arguments[0]);
  app.use.apply(app, arguments);
};

and I get the following before the server is started.

[Function: myMiddleware] <-- from grunt middleware option
[Function: staticMiddleware]
{ [Function: livereload] middlewarePriority: -1 }

myMiddleware is definitely loaded correctly - I see here in the console for every response. staticMiddlware is also definitely loaded - I can access the files in my build folder.

However, livereload isn't loaded correctly. I added some console.logs inside node_modules/grunt-express/node_modules/connect-livereload/index.js to see if it's ever called, and it isn't. In node_modules/grunt-express/lib/util.js, I've also added a console.log to rearrangeMiddleware:

exports.rearrangeMiddleware = function rearrangeMiddleware(server) {
  console.log("server.stack", server.stack);
  server.stack = (server.stack || []).sortBy(function(mw) {
    return mw.handle.middlewarePriority || 99;
  });
}

server.stack is undefined here, so I don't think middlewarePriority: -1 is working.

@azhang
Copy link
Author

azhang commented May 13, 2014

By the way I'm using express4. I know app.stack existed in express3 but not sure if that's the case anymore. I'll update when I find out.

update: app.stack in express3 is now app._router.stack in express4.

@azhang
Copy link
Author

azhang commented May 13, 2014

Pull request here: #62

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

1 participant