Leptos Forge build script library
Library to be used in your build scripts for
- Better output
- Support for the multiline text in the cargo build scripts
- Every lines of output starts with tags, to show where things happen
- colors to inform you how important message is
- Reliable tailwindcss integration
- Build your tailwind css file from source across dependencies
- Ability to watch for changes in your whole workspace and automatically recompile css when needed
- Reliable resource provisioning
- Uses
cargo_resourcesfor pulling resources from upstream crates withoutinclude_bytes! - Ability to watch for changes in your whole workspace and automatically refetch the resources when needed
- Uses
How to use it
Output
In your Cargo.toml add
[]
= "0.6"
In your build script:
use ;
Tailwind integration
Assuming your tailwind css files are located in assets/css/lib.css (relative to
respective Cargo.toml)
In your library crate Cargo.toml add (you don't need to depend on the leptos_forge_build_script here)
[]
=[
"src",
"assets"
]
[]
# Path to the main tailwind file for your crate
#
# Lib is the tailwind `main.css` without `@import "tailwind"`. import "tailwind"
# statement will be added for you automatically.
="assets/css/lib.css"
In your application Cargo.toml add
[]
="0.22.0"
= "0.6"
[]
# Path to the main tailwind file for your crate
#
# Lib is the tailwind `main.css` without `@import "tailwind"`. import "tailwind"
# statement will be added for you automatically.
="assets/css/lib.css"
# Path where the compiled css file should be
="target/resources/css/main.css"
In your application build script add
use current_dir;
use
use ;
[!NOTE]
Setting the fourth argument of
Tailwind::newtotruemakes theleptos_forge_build_scriptgeneratecargo::rerun-if-changed=statements, which disables the default build script behavior. Depending on your other use cases it might require to adjust your build script behavior.Cargo defaults can be brought back by adding
println!
Cargo toml configuration options for tailwind integration
[]
="relative/path/to/lib.css"
="relative/path/to/target/result.css"
=[]
-
lib - relative path to the tailwind configuration for this crate. This file will be imported from the generated tailwindcss file
-
output - optional, relative path to the output of the tailwindcss
-
watch - optional, list of paths which will be passed to
cargo::rerun-if-changed=PATHrelative to the crate Cargo.toml. If nonempty it will override the automatic path discovery.By default two paths are added:
- parent folder of the
lib.rsof the upstream crate - parent folder of the file pointed at in
libtailwind configuration option
The defaults are conservative and probably overly broad.
- parent folder of the
Resource provisioning
Resource provisioning in the build_script is a thin wrapper around the cargo_resources
itself.
First step is to setup your crates Cargo.toml as described in the cargo-resources documentation.
In your build script
use ;
[!NOTE]
Setting the second argument of
Resources::alltotruemakes theleptos_forge_build_scriptgeneratecargo::rerun-if-changed=statements, which disables the default build script behavior. Depending on your other use cases it might require to adjust your build script behavior.Cargo defaults can be brought back by adding
println!
Acknowledgement
Tailwind integration is based on cargo-resources
codebase.