Closed paveleremin closed 9 years ago
we updated to connect 3, there is no connect.static anymore, see https://github.com/gruntjs/grunt-contrib-connect#roll-your-own
That really isn't much of a migration path.
Perhaps the docs could say:
Connect 3 no longer uses connect.static
. Similar functionality is available using serve-static
. To use this:
serve-static
as a dependency in your project (or dev, basically alongside your grunt-contrib-connect
dependency): npm install --save serve-static
var serveStatic = require('serve-static');
connect.static
references to serveStatic
.Before:
return [
modRewrite(['^[^\\.]*$ /index.html [L]']),
connect.static('.tmp'),
connect().use(
'/bower_components',
connect.static('./bower_components')
),
connect.static(appConfig.app)
];
After:
return [
modRewrite(['^[^\\.]*$ /index.html [L]']),
serveStatic('.tmp'),
connect().use(
'/bower_components',
serveStatic('./bower_components')
),
serveStatic(appConfig.app)
];
Thanks @eddiemonge.
Thanks @eddiemonge
Does anyone get:
TypeError: object is not a function
for
connect().use(
'/bower_components',
connect.static('./bower_components')
),
Im confused how it worked in the first place because in
connect.static('.tmp'),
was used here as an object then right after connect().use(
is used as a function
I use serverStatic too and it works like a charme, what doesn't work is this:
...
// Make directory browse-able.
var directory = options.directory || options.base[options.base.length - 1];
middlewares.push(connect.directory(directory));
return middlewares;
...
connect.directory is not a function, is the error message, the same as for .static. How can I fix that? Couldn't find a solution.
If is not backwards compatible I think that version number should be changed to 1.[something].[something]. Read this: version [Major].[Minor].[Patch] Major = “breaking changes” – Increment MAJOR version when you have removed or changed a feature, and dependent modules will have to modified to be compatible with the new version.
Minor = “new feature” – Increment MINOR version when you have added a feature, but the module is backwards compatible.
Patch = “bugfix” – Increment PATCH version when you have fixed a problem, but not broken or changed anything else.
source: http://developer.telerik.com/featured/mystical-magical-semver-ranges-used-npm-bower/
return [ modRewrite(['^[^\.]*$ /index.html [L]']), connect.static('.tmp'), connect().use( '/bower_components', connect.static('./bower_components') ), connect.static(appConfig.app) ];
I've found the best solution to be roll-back
Spent 2 hours trying various suggested changes and nothing works.
Rolled back and it works like a charm
After update "grunt-contrib-connect" from ^0.7.1 to ^0.11.2, my code is broken:
now connect.static is undefined. Is it correct?