API Docs

Webpack integration for Flask.

class flask_webpackext.ext.FlaskWebpackExt(app=None)[source]

Flask-WebpackExt extension.

Extension initialization.

init_app(app)[source]

Flask application initialization.

init_config(app)[source]

Initialize configuration.

Proxies

Proxy to current extension.

flask_webpackext.proxies.current_manifest = <LocalProxy unbound>

Proxy to current manifest.

flask_webpackext.proxies.current_webpack = <LocalProxy unbound>

Proxy to current extension.

Manifest

Proxy to current extension.

class flask_webpackext.manifest.JinjaManifest[source]

Manifest entry which marks rendered strings as safe for Jinja.

Initialize manifest.

class flask_webpackext.manifest.JinjaManifestEntry(name, paths)[source]

Manifest entry which marks rendered strings as safe for Jinja.

Initialize manifest entry.

class flask_webpackext.manifest.JinjaManifestLoader(manifest_cls=<class 'flask_webpackext.manifest.JinjaManifest'>, entry_cls=<class 'flask_webpackext.manifest.JinjaManifestEntry'>)[source]

Factory which uses the Jinja manifest entry.

Initialize manifest loader.

load(filepath)[source]

Load a manifest from a file.

Project

Webpack project utilities for Flask-WebpackExt.

class flask_webpackext.project.WebpackBundleProject(import_name, project_folder=None, bundles=None, config=None, config_path=None)[source]

Flask webpack bundle project.

Initialize templated folder.

Parameters:
  • import_name – Name of the module where the WebpackBundleProject class is instantiated. It is used to determine the absolute path to the project_folder.
  • project_folder – Relative path to the Webpack project which is going to aggregate all the bundles.
  • bundles – List of flask_webpackext.bundle.WebpackBundle. This list can be statically defined if the bundles are known before hand, or dinamically generated using pywebpack.helpers.bundles_from_entry_point() so the bundles are discovered from the defined Webpack entrypoints exposed by other modules.
  • config – Dictionary which overrides the config.json file generated by Flask-WebpackExt. Use carefuly and only if you know what you are doing since config.json is the file that holds the key information to integrate Flask with Webpack.
  • config_path – Path where Flask-WebpackExt is going to write the config.json, this file is generated by flask_webpackext.project.flask_config().
class flask_webpackext.project.WebpackTemplateProject(import_name, project_folder=None, config=None, config_path=None)[source]

Flask webpack template project.

Initialize project.

Parameters:
  • import_name – Name of the module where the WebpackTemplateProject class is instantiated. It is used to determine the absolute path to the project_folder.
  • project_folder – Relative path to the Webpack project.
  • config – Dictionary which overrides the config.json file generated by Flask-WebpackExt. Use carefuly and only if you know what you are doing since config.json is the file that holds the key information to integrate Flask with Webpack.
  • config_path – Path where Flask-WebpackExt is going to write the config.json, this file is generated by flask_webpackext.project.flask_config().
flask_webpackext.project.flask_config()[source]

Flask configuration injected in Webpack.

Returns:Dictionary which contains the information Flask-WebpackExt knows about a Webpack project and the absolute URLs for static files and assets. The dictionary consists of a key build with the following keys inside:
  • debug: Boolean which represents if Flask debug is on.
  • context: Absolute path to the generated assets directory.
  • assetsPath: Absolute path to the generated static directory.
  • assetsURL: URL to access the built files.
  • staticPath: Absolute path to the generated static directory.
  • staticURL: URL to access the static files..

Bundle

Webpack bundle APIs for Flask-WebpackExt.

class flask_webpackext.bundle.WebpackBundle(import_name, folder, **kwargs)[source]

Flask webpack bundle.

Initialize bundle.

Parameters:
  • import_name – Name of the module where the WebpackBundle class is instantiated. It is used to determine the absolute path to the folder where the assets are located.
  • folder – Relative path to the assets.
  • kwargs – Keyword arguments directly passed to pywebpack.bundle.WebpackBundle.

Command Line Interface

flask webpack

Webpack commands.

flask webpack [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...

build

Run NPM build-script.

flask webpack build [OPTIONS] [ARGS]...

Arguments

ARGS

Optional argument(s)

buildall

Create, install and build webpack project.

flask webpack buildall [OPTIONS]

clean

Remove created webpack project.

flask webpack clean [OPTIONS]

create

Create webpack project. This will fetch the assets.

flask webpack create [OPTIONS]

install

Run NPM install.

flask webpack install [OPTIONS] [ARGS]...

Arguments

ARGS

Optional argument(s)

run

Run an NPM script.

flask webpack run [OPTIONS] SCRIPT [ARGS]...

Arguments

SCRIPT

Required argument

ARGS

Optional argument(s)