- Add platform-specific capability methods to PlatformService interface: - getExportInstructions() - getExportSuccessMessage() - needsSecondaryDownloadLink() - needsDownloadCleanup() - Update platform service implementations: - WebPlatformService: Implement web-specific export behavior - CapacitorPlatformService: Implement mobile-specific export behavior - ElectronPlatformService: Add placeholder for export functionality - PyWebViewPlatformService: Add placeholder for export functionality - Refactor DataExportSection component: - Remove direct platform checks (isWeb, isCapacitor, etc.) - Use platform service capabilities for UI behavior - Improve error handling and logging - Add proper cleanup for web platform downloads - Update PlatformServiceFactory: - Make getInstance() async to support dynamic imports - Improve platform service initialization - Fix code style and documentation: - Update JSDoc comments - Fix string quotes consistency - Add proper error handling - Improve logging messages - Update Vite config: - Add all Capacitor dependencies to external list - Ensure consistent handling across platforms
89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import dotenv from "dotenv";
|
|
import { loadAppConfig } from "./vite.config.utils.mts";
|
|
import path from "path";
|
|
import { fileURLToPath } from 'url';
|
|
|
|
// Load environment variables
|
|
dotenv.config();
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
export async function createBuildConfig(mode: string) {
|
|
const appConfig = await loadAppConfig();
|
|
const isElectron = mode === "electron";
|
|
const isCapacitor = mode === "capacitor";
|
|
const isPyWebView = mode === "pywebview";
|
|
|
|
// Explicitly set platform
|
|
process.env.VITE_PLATFORM = mode;
|
|
|
|
if (isElectron || isPyWebView || isCapacitor) {
|
|
process.env.VITE_PWA_ENABLED = 'false';
|
|
}
|
|
|
|
return {
|
|
base: isElectron || isPyWebView ? "./" : "/",
|
|
plugins: [vue()],
|
|
server: {
|
|
port: parseInt(process.env.VITE_PORT || "8080"),
|
|
fs: { strict: false },
|
|
},
|
|
build: {
|
|
outDir: isElectron ? "dist-electron" : "dist",
|
|
assetsDir: 'assets',
|
|
chunkSizeWarningLimit: 1000,
|
|
rollupOptions: {
|
|
external: isCapacitor
|
|
? [
|
|
'@capacitor/app',
|
|
'@capacitor/share',
|
|
'@capacitor/filesystem',
|
|
'@capacitor/camera',
|
|
'@capacitor/core'
|
|
]
|
|
: [
|
|
'@capacitor/app',
|
|
'@capacitor/share',
|
|
'@capacitor/filesystem',
|
|
'@capacitor/camera',
|
|
'@capacitor/core'
|
|
]
|
|
}
|
|
},
|
|
define: {
|
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
'process.env.VITE_PLATFORM': JSON.stringify(mode),
|
|
'process.env.VITE_PWA_ENABLED': JSON.stringify(!(isElectron || isPyWebView || isCapacitor)),
|
|
__dirname: isElectron ? JSON.stringify(process.cwd()) : '""',
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
...appConfig.aliasConfig,
|
|
'nostr-tools/nip06': mode === 'development'
|
|
? 'nostr-tools/nip06'
|
|
: path.resolve(__dirname, 'node_modules/nostr-tools/nip06'),
|
|
'nostr-tools/core': mode === 'development'
|
|
? 'nostr-tools'
|
|
: path.resolve(__dirname, 'node_modules/nostr-tools'),
|
|
'nostr-tools': path.resolve(__dirname, 'node_modules/nostr-tools'),
|
|
'dexie-export-import': path.resolve(__dirname, 'node_modules/dexie-export-import')
|
|
}
|
|
},
|
|
optimizeDeps: {
|
|
include: ['nostr-tools', 'nostr-tools/nip06', 'nostr-tools/core', 'dexie-export-import'],
|
|
exclude: isElectron ? [
|
|
'register-service-worker',
|
|
'workbox-window',
|
|
'web-push',
|
|
'serviceworker-webpack-plugin'
|
|
] : []
|
|
}
|
|
};
|
|
}
|
|
|
|
export default defineConfig(async () => createBuildConfig('web'));
|