Skip to main content

gocept.recipe.bowerstaticbundler

Bundling and minifying components included via bowerstatic.

This recipe imports you bowerstatic components, which you must specify in the recipes config (see below for details). It then retrieves your local components, calculates the import order and minifies and bundles JS and CSS files. The bundles are saved to your bower_components folder (or whatever folder you specified) as a new component called bowerstatic_bundle.

In your application you can then switch between bundled or non-bundled versions with an include helper function:

def bower_include(environ, name):
    if not os.environ.get('BOWERSTATIC_DEBUG'):
        name = 'bowerstatic_bundle'
    include = components.includer(environ)
    include(name)

In your view, where you normally get the includer and include your libraries, you now call:

bower_include(self.request.environ, '<you_library_name>')

This package uses rcssmin and rjsmin to minify CSS and JS files.

Configuration

Here is an example configuration for bowerstaticbundler:

[buildout]
parts += bundle

[bundle]
recipe = gocept.recipe.bowerstaticbundler
eggs = mypackage
       myotherpackage
modules = mypackage.browser.resource
          myotherpackage.browser.resource
bower = mypackage.bower
target_dir = ${config:bower_components}
environment = bundle-config

[bundle-config]
BOWER_COMPONENTS_DIR = ${config:bower_components}

You need to specify the location of your local components via the eggs and modules options. Eggs is needed to import your modules, where the components live, while modules specify the path to import them directly. This is needed as bower calculates the components and resources during import time, so we need to trigger them in the build step.

You also must provide the location of you bower singleton via the bower option.

target_dir specifies the directory, where the bundled component will be placed. It is recommended to point this to your bower_components folder, where your bower packages live, as bowerstatic will have to import the bundles as well in order to be able to include them into your Application.

With the environment option you can specify environment variables. In the example above we specify one environment variable called BOWER_COMPONENTS_DIR, which is the variable bower is looking for in the environment to get the installed bower packages. This might be different in your setup.

CHANGES

1.2.2 (2015-01-30)

  • Support for multiple local components.

1.2.1 (2015-01-14)

  • Also copy images into the bundle dir, which will be rendered as the fav icon.

  • Make generated .bower.json file more readable by adding newlines and indent.

  • When copying resources, create a separate directory for each package to reduce probability of name clashes.

1.2.0 (2015-01-13)

  • Copy all template files into the bundle dir, rather building one huge bundle.pt template

1.1.1 (2015-01-12)

  • Prevent error on update if bowerstatic_bundle directory is missing.

1.1 (2015-01-12)

  • Symlink additional resources references in CSS files (images, fonts, …) into the bundle and point minified CSS to these symlinks.

1.0.2 (2015-01-08)

  • Fixed handling of the pkg_resources working set when collecting resources from eggs.

  • Make sure recipe does not brake when there are no resources to bundle.

1.0.1 (2014-09-20)

  • Repair homepage url in setup.py.

1.0.0 (2014-09-20)

  • Initial release.

Release files for gocept.recipe.bowerstaticbundler 1.2.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 gocept.recipe.bowerstaticbundler 1.2.2
File Size Uploaded
gocept.recipe.bowerstaticbundler-1.2.2.zip 14.6 kB Details

Release files / gocept.recipe.bowerstaticbundler-1.2.2.zip

Download URL gocept.recipe.bowerstaticbundler-1.2.2.zip
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cbf2957474ca5fff8e3beb8e3e0c82a6b9d2d1ccf13a53164aa910d0f9a51b5b
BLAKE2b-256 checksum
How to use checksums
cacfc1cd2fb6d4bf54abd743d9baf6b112837b032004c0e2a684887a84e67e72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2.2 This release

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.1

1 release file

1.1

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

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