Skip to content

Commit 71d687b

Browse files
authored
feat(cli.rs): platform-specific conf.json (#2309)
1 parent 268450b commit 71d687b

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cli.rs": patch
3+
---
4+
5+
Merge platform-specific `tauri.linux.conf.json`, `tauri.windows.conf.json` and `tauri.macos.conf.json` into the config JSON from `tauri.conf.json`.

docs/api/config.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ The `tauri.conf.json` is a file generated by the `tauri init` command (see <a hr
1010

1111
Once generated, you may modify it at will to customize your Tauri application.
1212

13-
It's composed of the following properties:
13+
# Platform-specific configuration
14+
15+
In addition to the JSON defined on the `tauri.conf.json` file, Tauri reads a platform-specific configuration on `tauri.linux.conf.json`, `tauri.windows.conf.json` and `tauri.macos.conf.json` and merges it with the main `tauri.conf.json` configuration.
16+
17+
# Configuration structure
18+
19+
`tauri.conf.json` is composed of the following properties:
1420

1521
## `build`
1622

tooling/cli.rs/src/helpers/config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ fn get_internal(merge_config: Option<&str>, reload: bool) -> crate::Result<Confi
8484
merge(&mut config, &merge_config);
8585
}
8686

87+
let platform_config_filename = if cfg!(target_os = "macos") {
88+
"tauri.macos.conf.json"
89+
} else if cfg!(windows) {
90+
"tauri.windows.conf.json"
91+
} else {
92+
"tauri.linux.conf.json"
93+
};
94+
let platform_config_path = super::app_paths::tauri_dir().join(platform_config_filename);
95+
if platform_config_path.exists() {
96+
let platform_config_file = File::open(platform_config_path)?;
97+
let platform_config: JsonValue = serde_json::from_reader(BufReader::new(platform_config_file))
98+
.with_context(|| format!("failed to parse `{}`", platform_config_filename))?;
99+
merge(&mut config, &platform_config);
100+
}
101+
87102
#[allow(unused_mut)]
88103
let mut config: Config = serde_json::from_value(config)?;
89104
#[cfg(target_os = "linux")]

0 commit comments

Comments
 (0)