blob: ef1bffc97d3d90cb029831fbe4077a8aa69f8498 [file] [log] [blame]
Nils Diewald7cad8402014-07-08 17:06:56 +00001package Mojolicious::Plugin::AssetPack::LibSass;
2use Mojo::Base 'Mojolicious::Plugin';
3use CSS::Sass;
4use CSS::Minifier::XS;
5
6sub register {
7 my ($plugin, $mojo) = @_;
8
9 my $sass = CSS::Sass->new;
10
11 # Todo: Check if AssetPack is loaded
12 # Todo: Only minify if necessary
13
14 my $proc = $mojo->asset->preprocessors;
15
16 $proc->remove('scss');
17 $proc->add(
18 scss => sub {
19 my ($as, $text, $file) = @_;
20 $$text = CSS::Minifier::XS::minify($sass->compile($$text));
21 });
Nils Diewald7cad8402014-07-08 17:06:56 +000022};
23
241;
25
26__END__