Skip to main content

Flask-Bundler

Flask-Bundler allows you to serve your project assets from Webpack directly, allowing cache busting and easy deployment.

It uses Webpack's BundleTracker plugin to get information about the bundles in your configuration and to serve them.

Installation

You need to configure Webpack to output webpack-stats.json. For this, add webpack-bundle-tracker as a Node dependency to your project and in your webpack.config.js add:

const BundleTracker = require("webpack-bundle-tracker");
// ...
module.exports = {
    // ...
    plugins: [
        // ...
        new BundleTracker({
            filename: "./myapp/static/webpack-stats.json"
        }),
        // ...
    ],
    // ...
};

You can place the webpack-stats.json file anywhere in the application. By default Flask-Bundler will check for webpack-stats.json inside the application's static folder.

Afterwards, just initialize Flask-Bundler like you would with any extension.

Normal initialization

from flask import Flask
from flask_bundler import Bundler

app = Flask(__name__)
# ...
bundler = Bundler(app)

Application factory initialization

from flask import Flask
from flask_bundler import Bundler

bundler = Bundler()

def create_app():
    app = Flask(__name__)
    # ...
    bundler.init_app(app)
    # ...
    return app

Bundler options

When initializing Bundler, you can specify a few options.

stats_file

Path to the webpack-stats.json. Defaults to {app.static_folder}/webpack-stats.json.

custom_renderers

A dictionary of custom renderers. str.format will be called on the given string with the public path of the asset as the only parameter. The default renderers are css and js, but additional renderers can be passed if your application contains other types of outputs.

strict

If True, an error will be raised in exceptional situations. Otherwise, a warning will be issued and the empty string will be returned for the bundle.

License

© Efe Mert Demir 2020. This software is licensed under the BSD license.

Metadata

Release files for Flask-Bundler 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-Bundler 1.0.2
File Size Uploaded Provenance Actions
Flask-Bundler-1.0.2.tar.gz 4.0 kB Without provenance Details for Flask-Bundler-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for Flask-Bundler 1.0.2
File Interpreter ABI Platform Actions
Flask_Bundler-1.0.2-py3-none-any.whl Python 3 none any Details for Flask_Bundler-1.0.2-py3-none-any.whl

Total release size: 8.2 kB

Release files / Flask-Bundler-1.0.2.tar.gz

Download URL Flask-Bundler-1.0.2.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
98bb5ef95601a083104cd0c1eab8cf98931792bbbb8adab65e5d6bfeb8abc8b6
BLAKE2b-256 checksum
How to use checksums
979e4781bb9627c59985f0038a329671ad9fc36e0583b273f41242efbb2318a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.8.0 tqdm/4.41.1 CPython/3.7.6

Release files / Flask_Bundler-1.0.2-py3-none-any.whl

Download URL Flask_Bundler-1.0.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d95e2042cdef77e3abe93ed7cbf1037c972f8d5457f5e5002cb2b91bc753aa2e
BLAKE2b-256 checksum
How to use checksums
3191ae92abe6300d183d14130967a69fb5c4de7f3f4d9abf03f03b936fb2f69a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.8.0 tqdm/4.41.1 CPython/3.7.6

Security for Flask-Bundler 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page