core.filters

Extra webasset filters.

Classes

JsxFilter

DukPy is a simple javascript interpreter for Python built on top of

DataUriFilter

Overrides the default datauri filter to work around this issue:

RCSSMinFilter

Adds the rcssmin filter (not yet included in webassets)

Module Contents

class core.filters.JsxFilter(**kwargs)[source]

Bases: dukpy.webassets.BabelJSX

DukPy is a simple javascript interpreter for Python built on top of duktape engine without any external dependency.

Note: let is not supported by the duktape engine, see https://github.com/amol-/dukpy/issues/47.

name = 'jsx'[source]
babel_options: dict[str, Any][source]
input(_in: IO[str], out: IO[str], *, source_path: str | None = None, **kwargs: Any) None[source]
Parameters:

kwargs – are actually babel options

setup() None[source]

Overwrite this to have the filter do initial setup work, like determining whether required modules are available etc.

Since this will only be called when the user actually attempts to use the filter, you can raise an error here if dependencies are not matched.

Note: In most cases, it should be enough to simply define the options attribute. If you override this method and want to use options as well, don’t forget to call super().

Note: This may be called multiple times if one filter instance is used with different asset environment instances.

class core.filters.DataUriFilter(**kwargs)[source]

Bases: webassets.filter.datauri.CSSDataUri

Overrides the default datauri filter to work around this issue:

https://github.com/miracle2k/webassets/issues/387

name = 'datauri'[source]
input(_in: IO[str], out: IO[str], **kw: Any) None[source]

Implement your actual filter here.

This will be called for every source file.

property source_url: str[source]
property output_url: str[source]
class core.filters.RCSSMinFilter(**kwargs)[source]

Bases: webassets.filter.Filter

Adds the rcssmin filter (not yet included in webassets)

name = 'custom-rcssmin'[source]
setup() None[source]

Overwrite this to have the filter do initial setup work, like determining whether required modules are available etc.

Since this will only be called when the user actually attempts to use the filter, you can raise an error here if dependencies are not matched.

Note: In most cases, it should be enough to simply define the options attribute. If you override this method and want to use options as well, don’t forget to call super().

Note: This may be called multiple times if one filter instance is used with different asset environment instances.

output(_in: IO[str], out: IO[str], **kw: Any) None[source]

Implement your actual filter here.

This will be called for every output file.