From e69a18f29aa1ab90e935371f53a266be38fae7a0 Mon Sep 17 00:00:00 2001
From: SushilMallRC <sushil.mall@ringcentral.com>
Date: Mon, 26 Aug 2024 13:27:11 +0530
Subject: [PATCH] Fix webpack5 error Buffer is not defined

---
 utils/webpack.js | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/utils/webpack.js b/utils/webpack.js
index 5ddfa1d..01e060c 100644
--- a/utils/webpack.js
+++ b/utils/webpack.js
@@ -1,4 +1,6 @@
-function createConfig({entry, filename, outputPath, libraryName, externals}) {
+const webpack = require('webpack');
+
+function createConfig({ entry, filename, outputPath, libraryName, externals }) {
     const common = {
         mode: 'production',
         devtool: 'source-map',
@@ -12,6 +14,16 @@ function createConfig({entry, filename, outputPath, libraryName, externals}) {
                 },
             ],
         },
+        plugins: [
+            // Workaround for Buffer is undefined:
+            new webpack.ProvidePlugin({
+                Buffer: ['buffer', 'Buffer'],
+            }),
+            // Workaround for process is undefined:
+            new webpack.ProvidePlugin({
+                process: 'process/browser',
+            }),
+        ],
         resolve: {
             extensions: ['.tsx', '.ts', '.js'],
             fallback: {