Using IndexedDB with electron-webpack


#1

I’m working on an electron-webpack app that includes localforage as part of its operation.

I’ve run into some behaviour I’m not sure how to fix:

  • During hot reloads, localforage will pick up data previously persisted
  • Quitting the app completely then restarting it results in localforage being cleared. I think a new instance is created every time.

I think I’ve pinpointed it to the way electron and webpack interact. In particular, it seems like localforage or indexeddb is creating a folder associated with the webpack dev server’s randomly selected port:

vishalkuo@Vishal's Macbook Pro Desktop $ ll ~/Library/Application\ Support/Electron/IndexedDB/
total 0
8599808017 0 drwx------   8 vishalkuo  staff   256B  7 Jan 17:17 http_localhost_49381.indexeddb.leveldb
8599808128 0 drwx------   7 vishalkuo  staff   224B  7 Jan 17:18 http_localhost_50336.indexeddb.leveldb

Is there a way to

A) configure indexeddb to ignore the port and used a fixed directory name or
B) fix the webpack port?