-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open WebView Dev Tools on startup #1213
Comments
Sry but that is not the answer to the question. Thats a shortcut not a valid option to tell tauri always to open the devtools on startup. |
@pokecheater The PR linked above includes an example showing how you can open it on startup: 5832300#diff-cfab6e0634dd785c7949c059698552e4e8f6139ccbcdb29aeb6b4c29d57805b7. issue 3776 linked below that is indeed something else completely but it can use this same api to fix the shortcut (which is probably why this issue was linked). |
@FabianLars So here again: How to open the devtools automatically? This question still persists. Is there now a setting inside the tauri.conf.json or do I can open it with some tauri invoke call or something similar? I still have no idea. thx in advance. |
There is no explicit config/setting, only the rust api and i meant to show you the example in the code comment not just the code itself since you'll have to use Rust to make the devtools open at startup. If you bootstrap a new tauri app your main.rs file will have a small main function that should look like this // [...]
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
} Then we'll need to adapt it according to the example from above: // [...]
use tauri::Manager;
fn main() {
tauri::Builder::default()
.setup(|app| {
#[cfg(debug_assertions)]
app.get_window("main").unwrap().open_devtools(); // `main` is the first window from tauri.conf.json without an explicit label
Ok(())
})
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
} ( The |
For V2: pub fn run() {
tauri::Builder::default()
.setup(|app| {
#[cfg(debug_assertions)]
app.get_webview_window("main").unwrap().open_devtools();
Ok(())
})
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
} |
To debug it'd be very useful to have an option in the tauri.conf.json to open WebView Dev Tools on startup. AFAIK right now this always has to be done by right click and inspect an element, which gets annoying quite quickly if for some reason hot-reloading doesn't do it for you.
The text was updated successfully, but these errors were encountered: