Skip to content

Disable for Production

A possible setup to disable devtools in production using Rusts cfg macros

Rusts cfg macros can be used to conditionally disable or enable code. In the following snippet we use them to disable the devtools code in non-debug builds, i.e. when you build for production through cargo tauri build or cargo build --release.

fn main() {
let devtools = devtools::init(); // initialize the plugin as early as possible
let mut builder = tauri::Builder::default();
builder = builder.plugin(devtools); // then register it with Tauri!("./tauri.conf.json"))
.expect("error while running tauri application");