Skip to content

[docs] withGlobalTauri build option deprecated #9248

Description

@gronke

The build option withGlobalTauri as stated in Tauri v2 documentation does not work as expected:

image

% cargo tauri dev
    Error `tauri.conf.json` error on `build`: Additional properties are not allowed ('withGlobalTauri' was unexpected)

The migration script indicates the option was moved to the tauri property:

https://github.com/tauri-apps/tauri/blob/7898b601d14ed62053dd24011fabadf31ec1af45/tooling/cli/src/migrate/config.rs#L161C1-L179C2

fn process_build(config: &mut Map<String, Value>) {
  if let Some(build_config) = config.get_mut("build").and_then(|b| b.as_object_mut()) {
    if let Some(dist_dir) = build_config.remove("distDir") {
      build_config.insert("frontendDist".into(), dist_dir);
    }
    if let Some(dev_path) = build_config.remove("devPath") {
      let is_url = url::Url::parse(dev_path.as_str().unwrap_or_default()).is_ok();
      if is_url {
        build_config.insert("devUrl".into(), dev_path);
      }
    }
    if let Some(with_global_tauri) = build_config.remove("withGlobalTauri") {
      config
        .get_mut("tauri")
        .and_then(|t| t.as_object_mut())
        .map(|t| t.insert("withGlobalTauri".into(), with_global_tauri));
    }
  }
}
{
  "productName": "Tauri App",
  "version": "0.1.0",
  "identifier": "com.tauri.dev",
  "build": {
    "frontendDist": "../src"
  },
  "tauri": {
    "withGlobalTauri": true
  },
  // ...
}

This is not accepted either:

% cargo tauri dev
    Error `tauri.conf.json` error: Additional properties are not allowed ('tauri' was unexpected)

Expected Behavior

window.__TAURI__ is exposed on the application JS context.

Steps to reproduce

  1. Check out dev branch [7898b60]
  2. Install Tauri CLI
  3. Init new project
  4. Configure withGlobalTauri as documented on (https://beta.tauri.app/guides/frontend/trunk/#example-configuration)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions