#tauri-plugin-store set two data paths one for Dev and one for Production

6 messages · Page 1 of 1 (latest)

fickle stream
#

I have the tauri-plugin-store working great in an app. The issue is that my store is shared (on my dev machine) when using the app in production. I would like to somehow keep separate stores. One for dev and the other for production. (this of course is not an issue for users, just my own builds. I am also a user of the app. 😁 )

I use the JS API like so:

// database.js
import { Store } from 'tauri-plugin-store-api'

const db = new Store('./settings.db')

console.log(process.env.DEV) // Can't find variable: process as this is of course not a Node project

I would like something like this:

// psudo code
const db = isDEV ? new Store('./dev-settings.db') : new Store('./settings.db')

Hope what I'm looking for makes sense. Maybe have to do it on the Rust side and somehow pass that to the frontend?

icy mountain
#

Which could be written like this:

const db = import.meta.env.DEV ? new Store('./dev-settings.db') : new Store('./settings.db');
fickle stream
#

Brilliant!!! Works just as I need! I guess I need to get more familiar with vite.

#

tauri-plugin-store set two data paths one for Dev and one for Prodduction

#

tauri-plugin-store set two data paths one for Dev and one for Production