Note that there are some explanatory texts on larger screens.

plurals
  1. POexpress and connect-assetmanager
    text
    copied!<p>I am trying to use <a href="https://github.com/mape/connect-assetmanager" rel="nofollow">connect-assetmanager</a> with express. Apparently I don't understand how to adapt the connect-based example to an express app.</p> <p>I took the skeleton app that's created by the express command-line (scroll to bottom for commands I ran) and tried to merge into it the example from the connect-assetmanager home page. Here is my app.js:</p> <pre><code>var express = require('express') , routes = require('./routes') , assetManager = require('connect-assetmanager'); var assetManagerGroups = { 'css': { 'route': /\/static\/css\/[0-9]+\/.*\.css/ , 'path': './public/stylesheets/' , 'dataType': 'css' , 'files': [ 'style.css', 'style2.css' ] } }; var assetsManagerMiddleware = assetManager(assetManagerGroups); var app = module.exports = express.createServer(); app.configure(function(){ app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(app.router); app.use(assetsManagerMiddleware); app.use(express.static(__dirname + '/public')); app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); }); app.get('/', routes.index); </code></pre> <p>Then I modified layout.jade to have its style sheet reference point to the asset manager route: /static/css/style.css</p> <p>The welcome page loads (minus any styling) and in the chrome dev tools I see a failed request for the above css path. There are no errors in the node command window. Am I using the wrong approach to connecting the asset manager middleware to express? Or is it something stupid like reading the example regex incorrectly?</p> <p>For reference, here is what I ran to create the sample app:</p> <pre><code># using 2.5 since that's what the larger app is based on sudo npm install -g express@2.5.x # create the sample express app express expressAssetTest cd expressAssetTest # add connect-assetmanager to the dependencies echo '{ "name": "expressAssetTest" , "version": "0.0.1" , "private": true , "dependencies": { "express": "2.5.11" , "jade": "&gt;= 0.0.1" , "connect-assetmanager": "&gt;= 0.0.3" } }' &gt; package.json # add a 2nd stylesheet for testing purposes echo ".mycssclass { top: 0; }" &gt; public/stylesheets/style2.css sudo npm install </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload