import fs from 'fs/promises'; import path from 'path'; import { fileURLToPath } from 'url'; const BUGSNAG_API_KEY = process.env.BUGSNAG_API_KEY; const currentPath = fileURLToPath(import.meta.url); const projectRoot = path.dirname(currentPath); const htmlFilePath = path.resolve(projectRoot, '../dist/index.html'); try { const html = await fs.readFile(htmlFilePath, 'utf-8'); const scripts = ` `; const injectedHtml = html.replace( '
', `
\n${scripts}\n` ); await fs.writeFile(htmlFilePath, injectedHtml, 'utf-8'); console.log('Bugsnag scripts successfully injected.'); } catch (err) { console.error('Error injecting Bugsnag scripts:', err); }