TrevorBurnham/connect-assets — Issue #33: Problem wiring the middleware in
Author: scan
Created: 2011-10-28 20:47:59+00:00
State: open

Using this for the first time, and I thought this is just great, saving me a lot of time. CoffeeScript all the way.

But I have a bit of a trouble wiring it in. Surely I did something wrong, reading the `README` ten times did not help. My file structure is this:

/
assets/
styles.styl
app.coffee
server.js
public/
css/
js/
jquery.min.js

And my `app.coffee` is like this (relevant parts):

```coffeescript
express = require 'express'

app = module.exports = express.createServer()

oneYear = 31557600000

app.configure ->
app.set 'views', "#{__dirname}/views"
app.set 'view engine', 'coffee'
app.register '.coffee', require('coffeekup').adapters.express
#app.use require('stylus').middleware src: "#{__dirname}/public", dest: "#{__dirname}/public", compress: true
app.use require('connect-assets') src: "#{__dirname}/assets/"
app.use express.cookieParser()
app.use express.methodOverride()
app.use express.bodyParser()
app.use app.router

app.configure 'development', ->
app.use express.static "#{__dirname}/public"
app.use express.logger format: ':method :url'
app.use express.errorHandler dumpExceptions: true, showStack: true

app.configure 'production', ->
app.use express.static "#{__dirname}/public", maxAge: oneYear
app.use express.errorHandler()

app.get '/', (req, res) ->
res.render 'index', title: 'Express'
```

I am using [CoffeeKup](https://github.com/mauricemach/coffeekup) for the views, because I like CoffeeScript that much. My view:

```coffeescript
doctype 5
html ->
head ->
meta charset: 'utf-8'
title "#{@title or 'Untitled'}"
meta(name: 'description', content: @description) if @description?
css 'styles'
js 'jquery.min'
body @body or 'No content'
```

All right, so when I now open the route `'/'`, I get this error:

TemplateError: Error rendering /home/scan/Javascript/neighr/views/layout.coffee: No file found for route css/styles.css

It can't find `js/jquery.min.js` either when I comment out the `css` line.

CoffeeKup is similar to jade when it comes to external functions, according to their docs. So what did I do wrong?