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

Adding middleware w/ livereload breaks with grunt-contrib-connect 0.11.0 #112

Open
yankee42 opened this issue Jul 30, 2015 · 3 comments
Open

Comments

@yankee42
Copy link

The example "Adding the middleware - With Livereload" in the README.md breaks when updating grunt-contrib-connect to version 0.11.0 because the connect parameter is missing the methods static and directory. With version 0.10.1 it still works fine. Here is the error:

Running "connect:server" (connect) task
Warning: Object function createServer() {
  function app(req, res, next){ app.handle(req, res, next); }
  merge(app, proto);
  merge(app, EventEmitter.prototype);
  app.route = '/';
  app.stack = [];
  return app;
} has no method 'static' Use --force to continue.

The version history for grunt-contrib-connect says the change in this version was: update to connect 3.. I am not familiar with how connect works internally but I guess that the API has changed and the documentation here (README.md) needs to be changed as well.

@Nadrendion
Copy link

+1 I have the very same issue.

@whitetrefoil
Copy link

This seems work...

middleware: function(connect, options, middlewares) {
  middlewares.unshift(require('grunt-connect-proxy/lib/utils').proxyRequest);
  return middlewares;
}

@zeripath
Copy link

Hi!

So the issue appears to be that [email protected] moved to using [email protected] which has a different syntax for serving static files. I've just put a bug fix in to grunt-contrib-connect to ask them to make it clearer that the syntax has changed (grunt-contrib-connect#205) however, to be clearer here the fix is to:

  1. At the top of your Gruntfile.js you need to add:

    var serveStatic = require('serve-static');

  2. Then wherever connect.static is used you simply replace:

    connect.static(...) with: serveStatic(...)

Or at least that appears to be it!

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

4 participants