I try to include lokiJS (locla json database) to my vue-electron app from a vue-cli-plugin-electron-builder!.
src/db/db.js
const path = require('path')
import * as loki from 'lokijs';
const dbPath = path.resolve('src/db/db.json')
let db = new loki(dbPath);
export default db
src/main.js
import db from './db/db'
Vue.prototype.$db = db
src/components/component.vue
created() {
const db = this.$db;
db.loadDatabase({}, () => {
let rooms = db.getCollection("rooms");
this.rooms = rooms.find({ activ: true });
});
}
If I work in dev mode all works fine but when I build electron production app is import db from './db/db' not include. Thank you!
When you work in dev mode after build all the files kept inside the resource directory. like
But in case of prod
so first check where to kep this and how you try to access this db file .
Hope it will work.