blob: 6a082a439fa942207822c747b06c639cc7eccafb [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 });
22 $proc->map_type(scss => 'css');
23};
24
251;
26
27__END__