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 withfrom inside the public/coffee folder.
I've tried to modify the source paths inside the .js and .map files, with no success.