tauri-apps / tauri-apps/tauri-docs
Add guide: Conditional compilation
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 1.1k
- Forks
- 887
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 48
Description
TODO
Tauri exposes several environment variables to the beforeDevCommand and beforeBuildCommand, allowing frontend bundlers to perform conditional compilation. You can use this to write platform-specific JS code.
Details
JavaScript
-
only available with some bundlers (but most) -> called treeshaking
-
the cli exposes a set of environment variables
TAURI_PLATFORM- same astarget_osTAURI_ARCH- same astarget_archTAURI_FAMILY- same astarget_familyTAURI_PLATFORM_VERSION- version of the OSTAURI_PLATFORM_TYPE-"Linux" | "Darwin" | "Window_NT"same as nodejsos.type()TAURI_DEBUG- same asdebug_assertions
-
quick example
Rust
- link to conditional compilation guide https://doc.rust-lang.org/reference/conditional-compilation.html
- quick intro
cfg!and#[cfg()] - quick intro features
- target a specific OS (
target_osandtarget_family) - target a specific CPU architecture
cfg(debug_assertions)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the documentation section for build and development commands, then review the linked Rust conditional-compilation guide. Add a guide covering the listed JavaScript environment variables, treeshaking, and Rust cfg features, targets, architectures, and debug assertions, with quick examples for both languages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100