No matter what I do, when I enter a js file (http://localhost:3000/static/js/backbone.js
) in the url, it shows the last file asset manager cached. So in this case it is showing jquery.js
even though I entered backbone. Here is the code I am using:
var sys = require('sys');
var fs = require('fs');
var Connect = require('connect');
var assetManager = require('connect-assetmanager');
var assetHandler = require('connect-assetmanager-handlers');
var root = __dirname + '/public';
var Server = module.exports = Connect.createServer();
Server.use('/',
Connect.responseTime()
, Connect.logger()
);
var assetManagerGroups = {
'js': {
'route': /\/static\/js\/.*\.js/
, 'path': './public/js/'
, 'dataType': 'javascript'
, 'files': [
'jquery.js',
'backbone.js'
]
}
};
var assetsManagerMiddleware = assetManager(assetManagerGroups);
Server.use('/'
, assetsManagerMiddleware
, Connect.static(root)
);
Server.listen(3000);
Are you sure that jquery.js
and backbone.js
have not been merged into the same js
file that is returned by your request? This is the purpose of connect-assetmanager
.
Your assetManagerGroups
definition is basically saying for a request for any .js
file matched on the /static/js/
route, return a merged and minified version of jquery.js
and backbone.js
. The fact you are requesting backbone.js
is irrelevant.
This is nicely illustrated by the before and after image in the README, which shows multiple jquery
js
files bundled and returned into a single response to a request for client.js
.