Skip to content

Commit

Permalink
Add hooks (#221)
Browse files Browse the repository at this point in the history
* Add hooks example
* Add image for tailwindcss yew example
* Fix yew-tailwindcss example README.md
* Add changelog entry
  • Loading branch information
techninja1008 authored Aug 20, 2021
1 parent f47e83e commit 23a529b
Show file tree
Hide file tree
Showing 23 changed files with 818 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This changelog follows the patterns described here: https://keepachangelog.com/e
Subheadings to categorize changes are `added, changed, deprecated, removed, fixed, security`.

## Unreleased
### added
- Trunk now includes a hooks system. This improves many use cases where another build tool is needed alongside trunk, by allowing trunk to be configured to call them at various stages during the build pipeline. It is configured under `[[hooks]]` in `Trunk.toml`. More information can be found in the [Assets](https://trunkrs.dev/assets/) section of the docs.
- Added `trunk serve` autoreload triggered over websocket that reloads the page when a change is detected. The `--no-autoreload` flag disables this feature.

## 0.13.1
Expand Down
29 changes: 29 additions & 0 deletions Trunk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,32 @@ backend = "http://localhost:9000/"
# This proxy specifies only the backend, which is the only required field. In this example,
# request URIs are not modified when proxied.
backend = "http://localhost:9000/api/v2/"

## hooks
# Hooks are optional, and default to `None`.
# Hooks are executed as part of Trunk's main build pipeline, no matter how it is run.

[[hooks]]
# This hook example shows all the current available fields. It will execute the equivalent of
# typing "echo Hello Trunk!" right at the start of the build process (even before the HTML file
# is read). By default, the command is spawned directly and no shell is used.
stage = "pre_build"
command = "echo"
command_arguments = ["Hello", "Trunk!"]

[[hooks]]
# This hook example shows running a command inside a shell. As a result, features such as variable
# interpolation are available. This shows the TRUNK_STAGING_DIR environment variable, one of a set
# of default variables that Trunk inserts into your hook's environment. Additionally, this hook
# uses the build stage, meaning it executes in parallel with all of the existing asset pipelines.
stage = "build"
command = "sh"
command_arguments = ["-c", "echo Staging directory: $TRUNK_STAGING_DIR"]

[[hooks]]
# This hook example shows how command_arguments defaults to an empty list when absent. It also uses
# the post_build stage, meaning it executes after the rest of the build is complete, just before
# the staging directory is copied over the dist directory. This means that it has access to all
# built assets, including the HTML file generated by trunk.
stage = "post_build"
command = "ls"
Loading

0 comments on commit 23a529b

Please sign in to comment.