-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Describe the problem
As a Rust developer I have a certain love for the TOML format. There's nothing directly wrong with the JSON configuration file, it's just not as easy to manage as a TOML file. For example, you can't add comments in a JSON file, something that would be very useful for the Tauri config seeing as it has gotten pretty long, there's a lot of stuff to keep in memory regarding why you do things in your configs and it would be very nice to be able to put comments in there.
Describe the solution you'd like
Add the ability to write configurations in a Tauri.toml file, and/or directly in the Cargo.toml file. Due to best practises with Cargo.toml however it's probably best to use a Tauri.toml file.
# Tauri.toml
allowlist = { all = true }
[build]
beforeBuildCommand = "yarn build"
beforeDevCommand = "yarn dev"# Cargo.toml
[package.metadata.tauri]
allowlist = { all = true }
[package.metadata.tauri.build]
beforeBuildCommand = "yarn build"
beforeDevCommand = "yarn dev"Implementing this feature shouldn't be much more work than to find the configuration from either Cargo.toml or Tauri.toml, converting TOML into JSON, then passing it forward into existing functionality. As can be seen above with how I put allowlist at the root of the Tauri.toml file, it may be preferable to do some restructuring of the configurations if you add them to TOML since a Tauri.toml file containing a [tauri] section doesn't make much sense, but since that can make it a bit difficult to maintain both the JSON and TOML variants restructuring isn't really necessary.
Alternatives considered
Alternatively a less user friendly variant but makes it easier to maintain both the JSON and TOML variants:
[package.metadata.tauri]
config = {
# Pretty much just directly the contents of tauri.conf.json
}This variant might make it a bit easier to maintain both the JSON and TOML variants, since the other suggested solution may involve some slight restructuring of the config file.
Additional context
Here's a little utility function I wrote for Cargo Commander for converting JSON to Toml. Can be used as inspiration.
https://github.com/adaptive-simon/cargo-commander/blob/main/src/utils.rs#L240