jingo-minify icon indicating copy to clipboard operation
jingo-minify copied to clipboard

refactor less/stylus/sass support

Open willkg opened this issue 11 years ago • 3 comments

There are a lot of preprocessors out there and currently support for them is hard-coded into jingo-minify. This really needs a better solution.

At a minimum, it should get abstracted out. Maybe allow for plugin support for additional things so we don't have to maintain them all, too.

willkg avatar Mar 12 '13 01:03 willkg

SASS and Stylus support is pretty similar. The LESS support has an additional LESS_PREPROCESS thing.

In refactoring we should figure out whether to keep that functionality or ditch it. I'm inclined to ditch it for reduced complexity.

willkg avatar Mar 12 '13 22:03 willkg

yeah, I'd be a fan of ditching it. we're removing LESS_PREPROCESS from zamboni any day. (it's too slow for development.)

cvan avatar Mar 12 '13 22:03 cvan

django-compressor provides base classes for "filters" which you can subclass and thereby provide your own processing for whatever you want. I like this approach a lot. We create classes for which ever we want out-of-the-box support for, accept pull-requests for others, and allow people to easily define their own. We could auto-import a specific module name in apps (a la helpers.py for jingo), maybe minifiers.py, and auto-register classes to file extensions via metaclass. It's a common django pattern, and should be a lot easier on us.

from django.conf import settings

from jingo_minify.minifiers import BaseCompiler


class StylusCompiler(BaseCompiler):
    type = 'styl'
    bin = getattr(settings, 'STYLUS_BIN', 'stylus')
    command = '{bin} < {infile} > {outfile}'

That along with some hook methods for overriding could get us pretty far. The ones django-compressor has are fairly complex at this point, but I'm not sure ours would need to be.

pmclanahan avatar Mar 16 '13 16:03 pmclanahan