surganov
surganov

Reputation: 410

Render JS from CoffeeScript on client-side (on Node.js server)

How can I make this work?

This is my jade file:

!!!
html
head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
    sript(type='text/javascript', src='/javascripts/script.coffee')

I don't want to use any JavaScript in my project, so I'm using node-dev to run app.coffee instead of app.js for server. It works just fine for server-side coffee-files, but not for client-side.

I need some kind of render engine that could compile coffee-files on a fly, like stylus middleware:

app.use require('stylus').middleware(__dirname + '/public')
app.use express.static path.join __dirname, 'public'

Upvotes: 1

Views: 1128

Answers (2)

ckarbass
ckarbass

Reputation: 3681

Check out https://github.com/wdavidw/node-connect-coffee-script

I'd question the performance of any client side compilation for production apps.

Upvotes: 0

Michelle Tilley
Michelle Tilley

Reputation: 159115

There are several you might check out:

Personally I really like Browserify, as you can write your client-side CoffeeScript using the CommonJS module.exports style, but I've been meaning to check out webpack, which looks promising.

Upvotes: 2

Related Questions