Problem
I would like to import existing data into the Firebase emulators on start. Currently, there is no option in vite-plugin-firebase to do this.
Details
Local emulator data can be exported while the emulators are running with
npx firebase emulators:export <dir>
You can then import the data when the emulators start with
npx firebase emulators:start --import=<dir>
Solution
Add a config option that allows the import directory be specified. If the option exists, perform the import.
firebasePlugin({
projectName: 'whatever',
projectId: 'whatever-12345',
targets: ['firestore', 'functions', 'storage'],
showUI: true,
importPath: './data' // <--
}),
Workarounds
You can import while the emulators are running with the following, but it's inconvenient to have to always run two commands.
npx firebase emulators:exec --import=<dir>