[dancer-users] Dancer and Coffeescript

Pierre M piemas25 at gmail.com
Fri Oct 25 11:16:20 BST 2013


Hi everyone,

I have managed to make Coffeescript work with my Dancer2 app, but I'm
facing an additional challenge: Source maps won't work, and I'm guessing it
might be caused by my files structures. If anyone has managed to use Dancer
with Coffeescript's source maps, I would appreciate some help.

My file structure is simple: all my .coffee files are in public/coffee. And
their .js and .map counterparts are in this same folder too. Here is what
I've done in bin/app.pl to make my plack server compile the .coffee files
to .js:

#!/usr/bin/env perl
use FindBin;
use lib "$FindBin::Bin/../lib";

use HabitLab;
use Plack::Builder;

builder {

    enable 'Compile' => (   # Plack::Middleware::Compile
        pattern => qr{\.coffee$},
        lib     => 'public/coffee',
        blib    => 'public/coffee',
        mime    => 'text/plain',
        map     => sub {
            my $filename = shift;
            $filename =~ s/coffee$/js/;
            say "    * FILE: $filename";
            return $filename;
        },
        compile => sub {
            my ( $in, $out ) = @_;
            say "    * IN: $in, OUT: $out";
            system("coffee --compile --map --stdio < $in > $out");
        }
    );

    HabitLab->dance;
};

So far I've only created the .map files manually with

coffee -cm *.coffee

from inside the public/coffee folder.
I've tried to modify the source paths inside the .js and .map files, with
no success.

Any idea of what I might have missed?

---
I check email a couple times daily; to reach me sooner, you can send me a
text message via this page: https://awayfind.com/mascip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20131025/4704de8d/attachment-0001.html>


More information about the dancer-users mailing list