Skip to main content

plain.vendor

Download and manage vendored CSS and JavaScript dependencies from CDNs.

Overview

You can use plain vendor to download JavaScript and CSS files from CDNs and store them locally in your project. This keeps third-party assets under version control and avoids runtime dependencies on external CDNs.

Dependencies are configured in your pyproject.toml and downloaded to app/assets/vendor/.

# pyproject.toml
[tool.plain.vendor.dependencies]
htmx = {url = "https://unpkg.com/htmx.org@{version}/dist/htmx.min.js", installed = "2.0.4"}
alpine = {url = "https://cdn.jsdelivr.net/npm/alpinejs@{version}/dist/cdn.min.js", installed = "3.14.8"}

After configuring dependencies, run plain vendor sync to download them:

plain vendor sync

The files are saved to app/assets/vendor/ and can be included in your templates:

<script src="{{ 'vendor/htmx.min.js'|asset }}"></script>
<script src="{{ 'vendor/cdn.min.js'|asset }}"></script>

Adding dependencies

You can add a new dependency directly from the command line:

plain vendor add https://unpkg.com/htmx.org/dist/htmx.min.js

This downloads the file, extracts the version from the URL, and adds an entry to your pyproject.toml. You can also specify a custom name:

plain vendor add https://unpkg.com/htmx.org/dist/htmx.min.js --name htmx

Syncing dependencies

The sync command clears all existing vendored files and re-downloads everything from scratch:

plain vendor sync

Use this when you first clone a project or want to ensure your vendored files match your configuration.

Updating dependencies

The update command checks for newer versions and updates your pyproject.toml:

# Update all dependencies
plain vendor update

# Update specific dependencies
plain vendor update htmx alpine

The update process tries several strategies to find newer versions:

  1. Requests the "latest" tag (supported by many CDNs)
  2. Increments version numbers to probe for new releases

Configuration options

Custom filenames

If you want to rename a file when it's downloaded, use the filename option:

[tool.plain.vendor.dependencies]
htmx = {url = "https://unpkg.com/htmx.org@{version}/dist/htmx.min.js", installed = "2.0.4", filename = "htmx.js"}

Source maps

You can automatically download source maps alongside your vendored files:

[tool.plain.vendor.dependencies]
htmx = {url = "https://unpkg.com/htmx.org@{version}/dist/htmx.min.js", installed = "2.0.4", sourcemap = true}

When sourcemap = true, the tool appends .map to the filename and downloads from the same directory. For non-standard source map filenames, provide the filename directly:

[tool.plain.vendor.dependencies]
example = {url = "https://example.com/lib.min.js", installed = "1.0.0", sourcemap = "lib.min.js.map"}

You can also use the --sourcemap flag when adding dependencies:

plain vendor add https://unpkg.com/htmx.org/dist/htmx.min.js --sourcemap

Version placeholders

URLs can include a {version} placeholder that gets replaced with the installed version number:

htmx = {url = "https://unpkg.com/htmx.org@{version}/dist/htmx.min.js", installed = "2.0.4"}

When you run plain vendor sync, the placeholder is replaced with 2.0.4. This makes it easy to see which version is installed and enables the update command to try newer versions.

FAQs

What file types are supported?

The vendor tool accepts JavaScript (application/javascript, text/javascript), CSS (text/css), and JSON (application/json) files. Other content types will raise an error.

Where are vendored files stored?

All vendored files are downloaded to app/assets/vendor/. This directory is created automatically if it doesn't exist.

How does version detection work?

When you add a dependency or update to a new version, the tool parses version numbers from the final URL (after any redirects). It looks for patterns like 1.2.3 or 1.2 in the URL path.

What happens if a CDN is unavailable?

The sync and update commands will fail with an error if any dependency cannot be downloaded. You'll see which dependencies failed in the output.

Installation

Install the plain.vendor package from PyPI:

uv add plain.vendor

After installation, the plain vendor command becomes available. Configure your dependencies in pyproject.toml:

[tool.plain.vendor.dependencies]
htmx = {url = "https://unpkg.com/htmx.org@{version}/dist/htmx.min.js", installed = "2.0.4"}

Then run the sync command to download them:

plain vendor sync

Your vendored files will be available in app/assets/vendor/ and can be referenced in templates using the asset template filter.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plain_vendor-0.11.8.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plain_vendor-0.11.8-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file plain_vendor-0.11.8.tar.gz.

File metadata

  • Download URL: plain_vendor-0.11.8.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plain_vendor-0.11.8.tar.gz
Algorithm Hash digest
SHA256 e3fd4e0dcd2a1e2c97f5b51475f97f16bf54db330c8606ee4b470df1daa699cd
MD5 c0c29a292b58f58c9d3300e65a115c7a
BLAKE2b-256 5ce4ef773961811edb3d49195a91d788581e11a2830a573fa426841c3069af61

See more details on using hashes here.

File details

Details for the file plain_vendor-0.11.8-py3-none-any.whl.

File metadata

  • Download URL: plain_vendor-0.11.8-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plain_vendor-0.11.8-py3-none-any.whl
Algorithm Hash digest
SHA256 044b15970c1dcd84a450b063da984ee768d350ddb497e3c8af51480ea7e001d7
MD5 dbd44c5a32e49d5ce511bb9c501d0e4f
BLAKE2b-256 ea4e48000327b277862a3624bbcc4d0d57aa9a3732d9241aad0c70c88f4370f1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.11.8 This release

2 files

0.11.7

2 files

0.11.6

2 files

0.11.5

2 files

0.11.4

2 files

0.11.3

2 files

0.11.2

2 files

0.11.1

2 files

0.11.0

2 files

0.10.2

2 files

0.10.1

2 files

0.10.0

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

0.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page