Created
March 17, 2012 19:52
-
-
Save tig/2064777 to your computer and use it in GitHub Desktop.
Connect-assetmanager question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('./bootstrap/bootstrap'); | |
const express = require('express'); | |
const auth = require('connect-auth'); | |
const config = require('./config'); | |
const ConnectCouchDB = require('connect-couchdb')(express); | |
const assetManager = require('connect-assetmanager'); | |
const assetHandler = require('connect-assetmanager-handlers'); | |
const port = config.keys.port; | |
const session = { | |
secret: config.keys.sessionSecret, | |
cookie: { maxAge: 600000 }, | |
store: new ConnectCouchDB(config.keys.couchDbSessionStoreConfig) | |
}; | |
const authPlugins = auth.Facebook({ | |
appId: config.keys.fbId, | |
appSecret: config.keys.fbSecret, | |
scope: "email", | |
callback: config.keys.fbCallbackAddress | |
}); | |
var server = express.createServer(express.logger( ':method :url :status - :response-time ms' ), | |
express.responseTime(), | |
express.cookieParser(), | |
express.session( session ), | |
auth( authPlugins ), | |
express.bodyParser(), | |
express.router( config.routes ), | |
express.favicon(), | |
express.static( __dirname + '/../public' ), | |
express.errorHandler({ showStack: true, showMessage: true, dumpExceptions: true }) | |
); | |
server.set('views', __dirname + '/views'); | |
server.set('view engine', 'jade'); | |
server.set('view options', { layout: false }); | |
var root = __dirname + '/public'; | |
var assetManagerGroups = { | |
'js': { | |
'route': /\/static\/javascript\/[0-9]+\/.*\.js/ | |
, 'path': './public/javascript/' | |
, 'dataType': 'javascript' | |
, 'files': [ | |
'*' | |
] | |
}, 'css': { | |
'route': /\/static\/css\/[0-9]+\/.*\.css/ | |
, 'path': './public/css/' | |
, 'dataType': 'css' | |
, 'files': [ | |
'*' | |
] | |
, 'preManipulate': { | |
// Regexp to match user-agents including MSIE. | |
'MSIE': [ | |
assetHandler.yuiCssOptimize | |
, assetHandler.fixVendorPrefixes | |
, assetHandler.fixGradients | |
, assetHandler.stripDataUrlsPrefix | |
], | |
// Matches all (regex start line) | |
'^': [ | |
assetHandler.yuiCssOptimize | |
, assetHandler.fixVendorPrefixes | |
, assetHandler.fixGradients | |
, assetHandler.replaceImageRefToBase64(root) | |
] | |
} | |
} | |
}; | |
var assetsManagerMiddleware = assetManager(assetManagerGroups); | |
server.use('/' | |
, assetsManagerMiddleware | |
, express.static(root) | |
); | |
server.listen(port); | |
console.log("server listening at http://localhost:" + port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment