forked from jsnbuchanan/crowd-funder-for-time-pwa
- Fix logging levels: change verbose debugging from info to debug level - TestView: component mounting, boot-time config, URL flow testing - main.capacitor.ts: deeplink processing steps and router state - HomeView: API call details, component state updates, template rendering - Remove redundant environment variable override in vite.config.common.mts - Environment loading via dotenv works correctly - Manual override was defensive programming but unnecessary - Simplifies configuration and reduces maintenance burden - Add comprehensive Playwright timeout behavior documentation - README.md: detailed timeout types, failure behavior, debugging guide - TESTING.md: timeout failure troubleshooting and common scenarios - Clarifies that timeout failures indicate real issues, not flaky tests - Fix TypeScript configuration for .mts imports - tsconfig.node.json: add allowImportingTsExtensions for Vite config files - Resolves import path linting errors for .mts extensions All changes maintain existing functionality while improving code quality and reducing log noise in production environments.
119 lines
3.8 KiB
TypeScript
119 lines
3.8 KiB
TypeScript
import { defineConfig, UserConfig, Plugin } 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({ path: `.env.${process.env.NODE_ENV}` })
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
export async function createBuildConfig(platform: string): Promise<UserConfig> {
|
|
const appConfig = await loadAppConfig();
|
|
const isCapacitor = platform === "capacitor";
|
|
const isElectron = platform === "electron";
|
|
const isNative = isCapacitor || isElectron;
|
|
|
|
// Set platform - PWA is always enabled for web platforms
|
|
process.env.VITE_PLATFORM = platform;
|
|
|
|
// Environment variables are loaded from .env files via dotenv.config() above
|
|
|
|
return {
|
|
base: "/",
|
|
plugins: [vue()],
|
|
server: {
|
|
port: parseInt(process.env.VITE_PORT || "8080"),
|
|
fs: { strict: false },
|
|
// CORS headers disabled to allow images from any domain
|
|
// This means SharedArrayBuffer is unavailable, but absurd-sql
|
|
// will automatically fall back to IndexedDB mode which still works
|
|
},
|
|
build: {
|
|
outDir: "dist",
|
|
assetsDir: 'assets',
|
|
chunkSizeWarningLimit: 1000,
|
|
rollupOptions: {
|
|
output: {
|
|
format: 'esm',
|
|
generatedCode: {
|
|
preset: 'es2015'
|
|
},
|
|
manualChunks: undefined
|
|
}
|
|
}
|
|
},
|
|
worker: {
|
|
format: 'es',
|
|
plugins: () => []
|
|
},
|
|
// ESBuild configuration to fail on errors - TEMPORARILY DISABLED
|
|
// esbuild: {
|
|
// target: 'es2015',
|
|
// supported: {
|
|
// 'bigint': true
|
|
// },
|
|
// // Fail on any ESBuild errors
|
|
// logLevel: 'error',
|
|
// // Ensure build fails on syntax errors and other critical issues
|
|
// logOverride: {
|
|
// 'duplicate-export': 'error',
|
|
// 'duplicate-member': 'error',
|
|
// 'syntax-error': 'error',
|
|
// 'invalid-identifier': 'error'
|
|
// }
|
|
// },
|
|
|
|
define: {
|
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
'process.env.VITE_PLATFORM': JSON.stringify(platform),
|
|
// PWA is always enabled for web platforms
|
|
__dirname: JSON.stringify(process.cwd()),
|
|
__IS_MOBILE__: JSON.stringify(isCapacitor),
|
|
__IS_ELECTRON__: JSON.stringify(isElectron),
|
|
__USE_QR_READER__: JSON.stringify(!isCapacitor),
|
|
'process.platform': JSON.stringify('browser'),
|
|
'process.version': JSON.stringify('v16.0.0'),
|
|
'process.env.NODE_DEBUG': JSON.stringify(false),
|
|
'global.process': JSON.stringify({
|
|
platform: 'browser',
|
|
version: 'v16.0.0',
|
|
env: { NODE_DEBUG: false }
|
|
})
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src'),
|
|
'@nostr/tools': path.resolve(__dirname, 'node_modules/@nostr/tools'),
|
|
'@nostr/tools/nip06': path.resolve(__dirname, 'node_modules/@nostr/tools/nip06'),
|
|
...appConfig.aliasConfig,
|
|
'path': path.resolve(__dirname, './src/utils/node-modules/path.js'),
|
|
'fs': path.resolve(__dirname, './src/utils/node-modules/fs.js'),
|
|
'crypto': path.resolve(__dirname, './src/utils/node-modules/crypto.js'),
|
|
'dexie-export-import': path.resolve(__dirname, 'node_modules/dexie-export-import')
|
|
}
|
|
},
|
|
optimizeDeps: {
|
|
include: [
|
|
'@nostr/tools',
|
|
'@nostr/tools/nip06',
|
|
'@jlongster/sql.js',
|
|
'absurd-sql',
|
|
'absurd-sql/dist/indexeddb-main-thread',
|
|
'absurd-sql/dist/indexeddb-backend'
|
|
],
|
|
exclude: isNative ? [
|
|
'register-service-worker',
|
|
'workbox-window',
|
|
'web-push',
|
|
'serviceworker-webpack-plugin'
|
|
] : []
|
|
}
|
|
};
|
|
}
|
|
|
|
export default defineConfig(async () => createBuildConfig('web'));
|