#Where to put custom config entries?

8 messages · Page 1 of 1 (latest)

crude apex
#

I need to store some urls to be used for dynamically created webviews. How can I achieve this?

tacit rose
#

Do you need them in rust or javascript?
Do they change often?
You could look into https://tauri.app/v1/guides/building/resources/ if it's okay if the config ends up being a seperate file on the file system.
If not, then you could either make it part of your frontend (if it lands in the configured distDir tauri will include it in the binary and you can fetch it), or if you need it in Rust you can use the include_bytes!()/include_str!() macros.
Lastly, tauri.conf.json supports somewhat custom entries in the plugins section, for example ```json
{
"build": {},
...
"plugins": {
"mystore": {
"some-url": "https://..."
}
}
}

crude apex
#

I only need them in javascript and they don't change, but have different values depending on whether it's a development or production environment, e.g in dev we would just use http scheme, whereas in production https. Is there a better way to handle this?

tacit rose
#

i guess that would mainly depend on your frontend bundler/framework then. They typically already have dev/prod modes you could use to only bundle the data you'll actually need. Or if it's just a small amount of data, just include it all and set it depending on the window origin (if it's http://localhost:port it's dev, if not prod

crude apex
tacit rose
#

even if you don't have your own dev server (in case devPath is a file path) tauri has it's own dev server so what i said could still work.
In Rust you could check for if cfg!(dev) {} but the same is not available in js unless you have a frontend bundler that supports something like this (or if you pull it from rust with a tauri command)

vague briar
#

Hmm i think he is using typescript which probably mean it uses node.js for building project.. Then maybe he can use environment variable for distinguishing dev and prod too haha

crude apex