refactor: reorganize Vite config into modular files

Split monolithic vite.config.mjs into separate config files:
- vite.config.web.mts
- vite.config.electron.mts
- vite.config.capacitor.mts
- vite.config.pywebview.mts
- vite.config.common.mts
- vite.config.utils.mts

Updates:
- Modify package.json scripts to use specific config files
- Add electron-builder as dev dependency
- Update electron build configuration
- Fix electron resource paths
- Remove old vite.config.mjs and utils.js

This change improves maintainability by:
- Separating concerns for different build targets
- Making build configurations more explicit
- Reducing complexity in individual config files
This commit is contained in:
Matthew Raymer
2025-02-18 11:44:06 +00:00
parent 7f3114fd6c
commit 2746b8fe2b
14 changed files with 2831 additions and 187 deletions

16
src/main.capacitor.ts Normal file
View File

@@ -0,0 +1,16 @@
import { initializeApp } from "./main.common";
import { App } from "@capacitor/app";
import router from "./router";
const app = initializeApp();
// Handle deep links
App.addListener("appUrlOpen", (data: { url: string }) => {
console.log("Deep link opened:", data.url);
const slug = data.url.replace("timesafari://", "");
if (slug) {
router.push("/" + slug);
}
});
app.mount("#app");

40
src/main.common.ts Normal file
View File

@@ -0,0 +1,40 @@
import { createPinia } from "pinia";
import { App as VueApp, ComponentPublicInstance, createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import axios from "axios";
import VueAxios from "vue-axios";
import Notifications from "notiwind";
import "./assets/styles/tailwind.css";
import { FontAwesomeIcon } from "./lib/fontawesome";
import Camera from "simple-vue-camera";
// Global Error Handler
function setupGlobalErrorHandler(app: VueApp) {
app.config.errorHandler = (
err: unknown,
instance: ComponentPublicInstance | null,
info: string
) => {
console.error("Ouch! Global Error Handler.", err, info, instance);
alert(
(err instanceof Error ? err.message : "Something bad happened") +
" - Try reloading or restarting the app."
);
};
}
// Function to initialize the app
export function initializeApp() {
const app = createApp(App)
.component("fa", FontAwesomeIcon)
.component("camera", Camera)
.use(createPinia())
.use(VueAxios, axios)
.use(router)
.use(Notifications);
setupGlobalErrorHandler(app);
return app;
}

5
src/main.web.ts Normal file
View File

@@ -0,0 +1,5 @@
import { initializeApp } from "./main.common";
import "./registerServiceWorker"; // Web PWA support
const app = initializeApp();
app.mount("#app");