tauri-apps / tauri-apps/tauri-docs

Add guide: Conditional compilation

Open
#444 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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 as target_os
    • TAURI_ARCH - same as target_arch
    • TAURI_FAMILY - same as target_family
    • TAURI_PLATFORM_VERSION - version of the OS
    • TAURI_PLATFORM_TYPE - "Linux" | "Darwin" | "Window_NT" same as nodejs os.type()
    • TAURI_DEBUG - same as debug_assertions
  • quick example

Rust

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.