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.
My grunt express settings:
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.
and I get the following before the server is started.
myMiddlewareis definitely loaded correctly - I seeherein the console for every response.staticMiddlwareis also definitely loaded - I can access the files in mybuildfolder.However, livereload isn't loaded correctly. I added some console.logs inside
node_modules/grunt-express/node_modules/connect-livereload/index.jsto see if it's ever called, and it isn't. Innode_modules/grunt-express/lib/util.js, I've also added a console.log torearrangeMiddleware:server.stackisundefinedhere, so I don't thinkmiddlewarePriority: -1is working.