22// SPDX-License-Identifier: Apache-2.0
33// SPDX-License-Identifier: MIT
44
5+ //! The Tauri configuration used at runtime.
6+ //! It is pulled from a `tauri.conf.json` file and the [`Config`] struct is generated at compile time.
7+ //!
8+ //! # Stability
9+ //! This is a core functionality that is not considered part of the stable API.
10+ //! If you use it, note that it may include breaking changes in the future.
11+
512use std:: { collections:: HashMap , path:: PathBuf } ;
613
714use serde:: Deserialize ;
@@ -384,21 +391,21 @@ impl Default for TauriConfig {
384391pub struct BuildConfig {
385392 /// the devPath config.
386393 #[ serde( default = "default_dev_path" ) ]
387- pub dev_path : String ,
394+ pub dev_path : WindowUrl ,
388395 /// the dist config.
389396 #[ serde( default = "default_dist_path" ) ]
390- pub dist_dir : String ,
397+ pub dist_dir : WindowUrl ,
391398 /// Whether we should inject the Tauri API on `window.__TAURI__` or not.
392399 #[ serde( default ) ]
393400 pub with_global_tauri : bool ,
394401}
395402
396- fn default_dev_path ( ) -> String {
397- "http://localhost:8080" . to_string ( )
403+ fn default_dev_path ( ) -> WindowUrl {
404+ WindowUrl :: External ( Url :: parse ( "http://localhost:8080" ) . unwrap ( ) )
398405}
399406
400- fn default_dist_path ( ) -> String {
401- "../dist" . to_string ( )
407+ fn default_dist_path ( ) -> WindowUrl {
408+ WindowUrl :: App ( "../dist" . into ( ) )
402409}
403410
404411impl Default for BuildConfig {
@@ -762,8 +769,8 @@ mod build {
762769
763770 impl ToTokens for BuildConfig {
764771 fn to_tokens ( & self , tokens : & mut TokenStream ) {
765- let dev_path = str_lit ( & self . dev_path ) ;
766- let dist_dir = str_lit ( & self . dist_dir ) ;
772+ let dev_path = & self . dev_path ;
773+ let dist_dir = & self . dist_dir ;
767774 let with_global_tauri = self . with_global_tauri ;
768775
769776 literal_struct ! ( tokens, BuildConfig , dev_path, dist_dir, with_global_tauri) ;
@@ -915,8 +922,8 @@ mod test {
915922
916923 // create a build config
917924 let build = BuildConfig {
918- dev_path : String :: from ( "http://localhost:8080" ) ,
919- dist_dir : String :: from ( "../dist" ) ,
925+ dev_path : WindowUrl :: External ( Url :: parse ( "http://localhost:8080" ) . unwrap ( ) ) ,
926+ dist_dir : WindowUrl :: App ( "../dist" . into ( ) ) ,
920927 with_global_tauri : false ,
921928 } ;
922929
@@ -925,7 +932,10 @@ mod test {
925932 assert_eq ! ( b_config, build) ;
926933 assert_eq ! ( d_bundle, tauri. bundle) ;
927934 assert_eq ! ( d_updater, tauri. updater) ;
928- assert_eq ! ( d_path, String :: from( "http://localhost:8080" ) ) ;
935+ assert_eq ! (
936+ d_path,
937+ WindowUrl :: External ( Url :: parse( "http://localhost:8080" ) . unwrap( ) )
938+ ) ;
929939 assert_eq ! ( d_title, tauri. windows[ 0 ] . title) ;
930940 assert_eq ! ( d_windows, tauri. windows) ;
931941 }
0 commit comments