Skip to content

Commit f698ec3

Browse files
committed
Rename build namespace to plain.assets.build
`plain build` moved to `plain assets build` in the last commit, but the two contracts it reads still used the historical `plain.build` namespace: - `[tool.plain.build.run]` for user-defined build shell commands - `[project.entry-points."plain.build"]` for package build hooks Both move to `plain.assets.build` so the namespace follows the orchestrator that owns it. plain-tailwind and plain-esbuild update their entry-point group; plain-api and plain-tailwind READMEs update the TOML example.
1 parent f110a31 commit f698ec3

6 files changed

Lines changed: 22 additions & 6 deletions

File tree

plain-api/plain/api/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@ uv add --dev openapi-spec-validator
449449

450450
### Deploying
451451

452-
To build the JSON when you deploy, add a `build.run` command to your `pyproject.toml` file:
452+
To build the JSON when you deploy, add a build command to your `pyproject.toml` file:
453453

454454
```toml
455-
[tool.plain.build.run]
455+
[tool.plain.assets.build.run]
456456
openapi = {cmd = "plain api generate-openapi --validate > app/assets/openapi.json"}
457457
```
458458

plain-assets/plain/assets/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ By default, this [generates "fingerprinted" and compressed versions of the asset
5151

5252
The purpose of fingerprinting the assets is to allow the browser to cache them indefinitely. When the content of the file changes, the fingerprint will change, and the browser will use the newer file. This cuts down on the number of requests that your app has to handle related to assets.
5353

54+
### Pre-compile build steps
55+
56+
`plain assets build` runs three things in order before compiling assets:
57+
58+
1. User-defined shell commands from `[tool.plain.assets.build.run]` in your `pyproject.toml`. Useful for codegen that produces files into `app/assets/`:
59+
60+
```toml
61+
[tool.plain.assets.build.run]
62+
openapi = {cmd = "plain api generate-openapi --validate > app/assets/openapi.json"}
63+
```
64+
65+
2. Package-registered build hooks via the `plain.assets.build` entry-point group. Packages like `plain.tailwind` and `plain.esbuild` ship one of these to compile CSS / JS before the asset fingerprinter runs.
66+
67+
3. The asset compile itself (fingerprinting, compression).
68+
5469
## Using `AssetView` directly
5570

5671
In some situations you may want to use the `AssetView` at a custom URL, for example to serve a `favicon.ico`. You can do this quickly by using the `AssetView.as_view()` class method.

plain-assets/plain/assets/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def build(keep_original: bool, fingerprint: bool, compress: bool) -> None:
5959
for name, data in (
6060
pyproject.get("tool", {})
6161
.get("plain", {})
62+
.get("assets", {})
6263
.get("build", {})
6364
.get("run", {})
6465
.items()
@@ -70,7 +71,7 @@ def build(keep_original: bool, fingerprint: bool, compress: bool) -> None:
7071
sys.exit(result.returncode)
7172

7273
# Then run installed package build steps (like tailwind, esbuild)
73-
for entry_point in entry_points(group="plain.build"):
74+
for entry_point in entry_points(group="plain.assets.build"):
7475
print_event(f"{entry_point.name}...")
7576
entry_point.load()()
7677

plain-esbuild/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies = ["plain<1.0.0", "plain.assets>=0.1.0,<1.0.0"]
1111
[project.entry-points."plain.dev"]
1212
"esbuild" = "plain.esbuild.entrypoints:run_dev_build"
1313

14-
[project.entry-points."plain.build"]
14+
[project.entry-points."plain.assets.build"]
1515
"esbuild" = "plain.esbuild.entrypoints:run_build"
1616

1717
[tool.hatch.build.targets.wheel]

plain-tailwind/plain/tailwind/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ The build command automatically installs the Tailwind CLI if it is not present,
195195
You can automate this by adding a build command to your `pyproject.toml`:
196196

197197
```toml
198-
[tool.plain.build.run]
198+
[tool.plain.assets.build.run]
199199
tailwind = {cmd = "plain tailwind build --minify"}
200200
```
201201

plain-tailwind/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plain-tailwind = "plain.tailwind.cli:cli"
1616
[project.entry-points."plain.dev"]
1717
"tailwind" = "plain.tailwind.entrypoints:run_dev_build"
1818

19-
[project.entry-points."plain.build"]
19+
[project.entry-points."plain.assets.build"]
2020
"tailwind" = "plain.tailwind.entrypoints:run_build"
2121

2222
[tool.hatch.build.targets.wheel]

0 commit comments

Comments
 (0)