diff --git a/docs/configuration.rst b/docs/configuration.rst index 4385e234..b9c5bd8e 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -107,6 +107,15 @@ Group options Defaults to ``True``. +``enable_min`` +.............. + + **Optional** + + Indicates if you want this group to be minified or not. + + Defaults to ``True``. + Other settings -------------- diff --git a/pipeline/compressors/__init__.py b/pipeline/compressors/__init__.py index 4eabc380..714924fe 100644 --- a/pipeline/compressors/__init__.py +++ b/pipeline/compressors/__init__.py @@ -51,7 +51,7 @@ def js_compressor(self): def css_compressor(self): return to_class(settings.PIPELINE_CSS_COMPRESSOR) - def compress_js(self, paths, templates=None, **kwargs): + def compress_js(self, paths, enable_min=True, templates=None, **kwargs): """Concatenate and compress JS files""" js = self.concatenate(paths) if templates: @@ -61,16 +61,16 @@ def compress_js(self, paths, templates=None, **kwargs): js = "(function() { %s }).call(this);" % js compressor = self.js_compressor - if compressor: + if compressor and enable_min: js = getattr(compressor(verbose=self.verbose), 'compress_js')(js) return js - def compress_css(self, paths, output_filename, variant=None, **kwargs): + def compress_css(self, paths, output_filename, enable_min=True, variant=None, **kwargs): """Concatenate and compress CSS files""" css = self.concatenate_and_rewrite(paths, output_filename, variant) compressor = self.css_compressor - if compressor: + if compressor and enable_min: css = getattr(compressor(verbose=self.verbose), 'compress_css')(css) if not variant: return css diff --git a/pipeline/packager.py b/pipeline/packager.py index 5acda214..bb41f2bb 100644 --- a/pipeline/packager.py +++ b/pipeline/packager.py @@ -59,6 +59,10 @@ def variant(self): def manifest(self): return self.config.get('manifest', True) + @property + def enable_min(self): + return self.config.get('enable_min', True) + class Packager(object): def __init__(self, storage=default_storage, verbose=False, css_packages=None, js_packages=None): @@ -101,7 +105,7 @@ def pack(self, package, compress, signal, **kwargs): if self.verbose: print("Saving: %s" % output_filename) paths = self.compile(package.paths, force=True) - content = compress(paths, **kwargs) + content = compress(paths, enable_min=package.enable_min, **kwargs) self.save_file(output_filename, content) signal.send(sender=self, package=package, **kwargs) return output_filename