Closed nckh closed 12 years ago
Where do the files end up?
Also, I recommend setting log_level
to 'debug' to get way more info about the compilation process.
Thanks for your reply. It seems no file is compiled in that case.
So here is my code:
connect = require 'connect'
compiler = require 'connect-compiler'
server = connect()
server.use connect.logger 'tiny'
server.use compiler
enabled: 'coffee'
src: 'src/coffee'
dest: 'public/js'
log_level: 'debug'
server.use connect.static "#{__dirname}/public"
server.listen 3001
What I get when launching the server:
compiler.setup()
{ enabled: [ 'coffee' ],
roots: [ [ 'src/coffee', 'public/js' ] ],
mount: '',
delta: null,
expires: false,
log_level: 10,
create_dirs: true,
external_timeout: 3000,
cascade: false,
ignore: /\.(jpe?g|gif|png)$/i,
resolve_index: false,
allowed_methods: [ 'GET' ],
options: { all: {} } }
And what I get when index.html tries to load js/lib.js:
>>>> [compiler] (0) Checking 'coffee'...
DEBUG coffee /js/lib.js run()
DEBUG coffee /js/lib.js roots: [ [ 'src/coffee', 'public/js' ] ]
DEBUG coffee /js/lib.js matches(src/coffee, /js/lib.js)
DEBUG coffee /js/lib.js pairs: [ [ 'src/coffee/js/lib.coffee', 'public/js' ] ]
DEBUG coffee /js/lib.js validate( [src/coffee/js/lib.coffee,public/js], function )
DEBUG coffee /js/lib.js validate( [], function )
DEBUG coffee /js/lib.js No matching sources.
>>>> [compiler] Completed 'coffee'! (ok=false, err=null) --> success=false
>>>> [compiler] Done! (success=false)
GET /js/lib.js 404 - - 7 ms
But no issue with `dest: 'public'`. I get the following instead:
>>>> [compiler] (0) Checking 'coffee'...
DEBUG coffee /lib.js run()
DEBUG coffee /lib.js roots: [ [ 'src/coffee', 'public' ] ]
DEBUG coffee /lib.js matches(src/coffee, /lib.js)
DEBUG coffee /lib.js pairs: [ [ 'src/coffee/lib.coffee', 'public' ] ]
DEBUG coffee /lib.js validate( [src/coffee/lib.coffee,public], function )
DEBUG coffee /lib.js validated src! srcStat: src: src/coffee/lib.coffee destDir: public
DEBUG coffee /lib.js destValid( public/lib.js, function )
DEBUG coffee /lib.js stale( object, object, function )
INFO coffee /lib.js writing { rc/coffee/lib.coffee --> ublic/lib.js }
DEBUG coffee /lib.js Success!
>>>> [compiler] Completed 'coffee'! (ok=true, err=null) --> success=true
>>>> [compiler] Done! (success=true)
GET /lib.js 200 53 - 15 ms
Where's the actual file? I suspect it's src/coffee/lib.js
. Remember, the compiler maps requests directly from $SRC/$path
(with the proper extension) to $DEST/$path
-- so /js/lib.js
will be $path
, and search src/coffee/js/lib.coffee
, writing to dest/js/js/lib.js
if found.
It looks like you want to drop the js
part when doing the lookup, which is what the mount
option is for:
connect = require 'connect'
compiler = require 'connect-compiler'
server = connect()
server.use connect.logger 'tiny'
server.use compiler
enabled: 'coffee'
src: 'src/coffee'
dest: 'public/js'
mount: 'js'
log_level: 'debug'
server.use connect.static "#{__dirname}/public"
server.listen 3001
I think that'll do what you want.
Oh I see. Sorry it looks I didn't get the way it works internally. Thank you very much :)
Glad I could help!
Hi! For some unknown reason I cannot make the compiler work when the dest folder is a subfolder of my static folder.
Is it a bug or am I doing something wrong? Thanks for your help!