Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added flag to pipeline group package config to allow on per group basis... #363

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------
Expand Down
8 changes: 4 additions & 4 deletions pipeline/compressors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion pipeline/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down