@ -12,17 +12,66 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export async function createBuildConfig(platform: string): Promise<UserConfig> {
console.log(`[VITE CONFIG] createBuildConfig called with platform: ${platform}`);
console.log(`[VITE CONFIG] NODE_ENV: ${process.env.NODE_ENV}`);
console.log(`[VITE CONFIG] VITE_PLATFORM: ${process.env.VITE_PLATFORM}`);
const appConfig = await loadAppConfig();
const isCapacitor = platform === "capacitor";
const isElectron = platform === "electron";
const isNative = isCapacitor || isElectron;
console.log(`[VITE CONFIG] Platform flags - isCapacitor: ${isCapacitor}, isElectron: ${isElectron}, isNative: ${isNative}`);
// Set platform - PWA is always enabled for web platforms
process.env.VITE_PLATFORM = platform;
console.log(`[VITE CONFIG] Set VITE_PLATFORM to: ${platform}`);
return {
const config: UserConfig = {
base: "/",
plugins: [vue()],
plugins: [
{
name: 'vite-config-logger',
config(config, { command, mode }) {
console.log(`[VITE CONFIG] Plugin config called - command: ${command}, mode: ${mode}`);
console.log(`[VITE CONFIG] Current config keys:`, Object.keys(config || {}));
return config;
},
configResolved(config) {
console.log(`[VITE CONFIG] Config resolved - mode: ${config.mode}, command: ${config.command}`);
console.log(`[VITE CONFIG] Plugins found:`, config.plugins.map(p => p.name).filter(Boolean));
console.log(`[VITE CONFIG] Build target:`, config.build?.target);
console.log(`[VITE CONFIG] Minify setting:`, config.build?.minify);
}
},
// Plugin to explicitly handle HTML elements that Vue might treat as components
{
name: 'vue-html-elements',
transform(code, id) {
if (id.endsWith('.vue')) {
console.log(`[VUE HTML PLUGIN] Processing Vue file: ${id}`);
// This plugin ensures that HTML elements like <b> are treated as HTML elements
// The actual transformation is handled by the Vue compiler configuration above
}
return code;
}
},
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => {
console.log(`[VUE COMPILER] isCustomElement called for tag: "${tag}"`);
// Only treat SVG elements as custom elements
// This prevents warnings when using v-html with SVG content from libraries like jdenticon
// Don't treat single-letter tags as custom elements to avoid Vue warnings about <b>, <i>, etc.
const result = tag.startsWith('svg') || tag.startsWith('SVG');
console.log(`[VUE COMPILER] isCustomElement result for "${tag}": ${result}`);
return result;
}
}
}
})
],
server: {
port: parseInt(process.env.VITE_PORT || "8080"),
fs: { strict: false },
@ -93,6 +142,11 @@ export async function createBuildConfig(platform: string): Promise<UserConfig> {
] : []
}
};
console.log(`[VITE CONFIG] Final config object keys:`, Object.keys(config));
console.log(`[VITE CONFIG] Vue plugin configuration:`, JSON.stringify(config.plugins?.find(p => typeof p === 'object' && p && 'name' in p && p.name === 'vue') || 'Not found'));
return config;
}
export default defineConfig(async () => createBuildConfig('web'));