fix: update Vue template syntax and improve Vite config

- Fix Vue template syntax in App.vue by using proper event handler format
- Update Vite config to properly handle ESM imports and crypto modules
- Add manual chunks for better code splitting
- Improve environment variable handling in vite-env.d.ts
- Fix TypeScript linting errors in App.vue
This commit is contained in:
Matthew Raymer
2025-04-18 09:59:33 +00:00
parent 62553a37aa
commit e5518cd47c
161 changed files with 12154 additions and 11570 deletions

View File

@@ -1,33 +1,34 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import { fileURLToPath, URL } from 'node:url';
import { fileURLToPath } from 'url';
// Determine if we're building for mobile based on environment variable
const isMobile = process.env.VITE_PLATFORM === 'capacitor';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig(({ mode }) => {
return {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@': path.resolve(__dirname, './src'),
'nostr-tools': path.resolve(__dirname, 'node_modules/nostr-tools'),
'nostr-tools/nip06': path.resolve(__dirname, 'node_modules/nostr-tools/nip06'),
'nostr-tools/core': path.resolve(__dirname, 'node_modules/nostr-tools/core'),
stream: 'stream-browserify',
util: 'util',
crypto: 'crypto-browserify'
'crypto': path.resolve(__dirname, 'node_modules/crypto-browserify'),
'stream': path.resolve(__dirname, 'node_modules/stream-browserify'),
'buffer': path.resolve(__dirname, 'node_modules/buffer/'),
},
mainFields: ['module', 'jsnext:main', 'jsnext', 'main'],
},
optimizeDeps: {
include: ['nostr-tools', 'nostr-tools/nip06', 'nostr-tools/core'],
esbuildOptions: {
define: {
global: 'globalThis'
}
}
include: [
'crypto-browserify',
'stream-browserify',
'buffer'
]
},
define: {
__USE_QR_READER__: JSON.stringify(!isMobile),