blob: 6a082a439fa942207822c747b06c639cc7eccafb [file] [log] [blame]
package Mojolicious::Plugin::AssetPack::LibSass;
use Mojo::Base 'Mojolicious::Plugin';
use CSS::Sass;
use CSS::Minifier::XS;
sub register {
my ($plugin, $mojo) = @_;
my $sass = CSS::Sass->new;
# Todo: Check if AssetPack is loaded
# Todo: Only minify if necessary
my $proc = $mojo->asset->preprocessors;
$proc->remove('scss');
$proc->add(
scss => sub {
my ($as, $text, $file) = @_;
$$text = CSS::Minifier::XS::minify($sass->compile($$text));
});
$proc->map_type(scss => 'css');
};
1;
__END__