From f3405abadb7514f5830d57f251b0e758b2a66313 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Thu, 16 Oct 2025 18:21:15 +0200 Subject: [PATCH] Copies bundle to CE and Pro backend Copies the generated bundle to both the CE and Pro backend directories during the build process. This ensures that the webcomponent is readily available for both versions, streamlining the deployment process. It also introduces improved logging and error handling to provide better visibility into the copying process. --- .../frontend/webcomponent/rollup.config.js | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/meet-ce/frontend/webcomponent/rollup.config.js b/meet-ce/frontend/webcomponent/rollup.config.js index a92a48d..8b5d874 100644 --- a/meet-ce/frontend/webcomponent/rollup.config.js +++ b/meet-ce/frontend/webcomponent/rollup.config.js @@ -5,8 +5,12 @@ import typescript from '@rollup/plugin-typescript' import terser from '@rollup/plugin-terser' import postcss from 'rollup-plugin-postcss' import fs from 'fs' +import path from 'path' +import { fileURLToPath } from 'url' const production = !process.env.ROLLUP_WATCH +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) export default { input: 'src/index.ts', @@ -71,13 +75,39 @@ export default { { name: 'copy-bundle', writeBundle () { - const dir = '../../backend/public/webcomponent' const bundleName = 'openvidu-meet.bundle.min.js' - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir, { recursive: true }) + const sourcePath = path.resolve(__dirname, './dist', bundleName) + + if (!fs.existsSync(sourcePath)) { + console.warn(`⚠️ Bundle not found at ${sourcePath}, skipping copy.`) + return + } + + // 1. Copy to CE backend + const ceDir = path.resolve(__dirname, '../../backend/public/webcomponent') + try { + if (!fs.existsSync(ceDir)) fs.mkdirSync(ceDir, { recursive: true }) + fs.copyFileSync(sourcePath, path.join(ceDir, bundleName)) + console.log(`✅ Bundle copied to CE: ${ceDir}/${bundleName}`) + } catch (err) { + console.error(`❌ Failed to copy bundle to CE: ${err}`) + } + + // 2. Copy to Pro backend if it exists + const proDir = path.resolve(__dirname, '../../../meet-pro') + const webcomponentProDir = path.join(proDir, 'backend/public/webcomponent') + + try { + if (fs.existsSync(proDir) && fs.lstatSync(proDir).isDirectory()) { + if (!fs.existsSync(webcomponentProDir)) fs.mkdirSync(webcomponentProDir, { recursive: true }) + fs.copyFileSync(sourcePath, path.join(webcomponentProDir, bundleName)) + console.log(`✅ Bundle copied to PRO: ${webcomponentProDir}/${bundleName}`) + } else { + console.log(`ℹ️ PRO directory does not exist, skipping copy: ${proDir}`) + } + } catch (err) { + console.error(`❌ Failed to copy bundle to PRO: ${err}`) } - fs.copyFileSync(`./dist/${bundleName}`, `${dir}/${bundleName}`) - console.log(`✅ Bundle copied to ${dir}/${bundleName}`) } } ]