betty.extension.webpack package - Betty 0.4.0a3 documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.extension.webpack package

## Subpackages

- betty.extension.webpack.jinja2 package
  - Submodules
    - betty.extension.webpack.jinja2.filter module
      - `filter_webpack_entry_point_js()`
  - Module contents

## Submodules

- betty.extension.webpack.build module
  - `Builder`
    - `Builder.__init__()`
    - `Builder.build()`
  - `webpack_build_id()`

## Module contents

Integrate Betty with Webpack.

This module is internal.

class betty.extension.webpack.PrebuiltAssetsRequirement

  Bases: `Requirement`

  Check if prebuilt assets are available.

  async is_met() → bool

    Check if the requirement is met.

    Return type:

      `bool`

  async summary() → betty.locale.localizable.Localizable

    Get the requirement’s human-readable summary.

    Return type:

      `betty.locale.localizable.Localizable`

final class betty.extension.webpack.Webpack

  Bases: `Extension`, `CssProvider`, `Jinja2Provider`, `Generator`

  Integrate Betty with Webpack.

  This is internal. It MAY be used anywhere in Betty’s source code, but MUST NOT be used by third-party code.

  Parameters:

    - project (`betty.project.Project`)

    - args (`typing.Any`)

    - kwargs (`typing.Any`)

  classmethod assets_directory_path() → pathlib.Path

    Return the path on disk where the extension’s assets are located.

    This may be anywhere in your Python package.

    Return type:

      `pathlib.Path`

  build_requirement() → betty.requirement.Requirement

    Get the requirement that must be satisfied for Webpack builds to be available.

    Return type:

      `betty.requirement.Requirement`

  classmethod enable_requirement() → betty.requirement.Requirement

    Define the requirement for this extension to be enabled.

    This defaults to the extension’s dependencies.

    Return type:

      `betty.requirement.Requirement`

  property filters: dict[str, Callable[[...], Any]]

    Jinja2 filters provided by this extension.

    Keys are filter names, and values are the filters themselves.

  async generate(job_context: betty.generate.GenerationContext) → None

    Generate (part of) a project’s site.

    Parameters:

      job_context (`betty.generate.GenerationContext`)

    Return type:

      `None`

  new_context_vars() → dict[str, Any]

    Create new variables for a new `jinja2.runtime.Context`.

    Keys are the variable names, and values are variable values.

    Return type:

      `dict`[`str`, `typing.Any`]

  classmethod plugin_id() → str

    Get the plugin ID.

    IDs are unique per plugin type: - A plugin repository MUST at most have a single plugin for any ID. - Different plugin repositories MAY each have a plugin with the same ID.

    Return type:

      `str`

  classmethod plugin_label() → betty.locale.localizable.Localizable

    Get the human-readable short plugin label.

    Return type:

      `betty.locale.localizable.Localizable`

  async prebuild(job_context: betty.job.Context) → None

    Prebuild the Webpack assets.

    Parameters:

      job_context (`betty.job.Context`)

    Return type:

      `None`

  property public_css_paths: list[str]

    The public URL paths to the CSS files to include in each HTML page.

class betty.extension.webpack.WebpackEntryPointProvider

  Bases: `ABC`

  An extension that provides Webpack entry points.

  abstract webpack_entry_point_cache_keys() → collections.abc.Sequence[str]

    Get the keys that make a Webpack build for this provider unique.

    Providers that can be cached regardless may `return ()`.

    Return type:

      `collections.abc.Sequence`[`str`]

  abstract classmethod webpack_entry_point_directory_path() → pathlib.Path

    Get the path to the directory with the entry point assets.

    The directory must include at least a `package.json` and `main.ts`.

    Return type:

      `pathlib.Path`