From 9f25d5aa5966e587bd675600541692915f332571 Mon Sep 17 00:00:00 2001 From: dxlin Date: Wed, 9 Aug 2023 01:14:37 -0400 Subject: [PATCH] Work around for Buffer is undefined https://stackoverflow.com/questions/68707553/uncaught-referenceerror-buffer-is-not-defined https://github.com/webpack/changelog-v5/issues/10 --- .webpack/webpack.base.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.webpack/webpack.base.js b/.webpack/webpack.base.js index 347c02de226..5de575af8df 100644 --- a/.webpack/webpack.base.js +++ b/.webpack/webpack.base.js @@ -131,7 +131,12 @@ module.exports = (env, argv, { SRC_DIR, ENTRY }) => { extensions: ['.js', '.jsx', '.json', '.ts', '.tsx', '*'], // symlinked resources are resolved to their real path, not their symlinked location symlinks: true, - fallback: { fs: false, path: false, zlib: false }, + fallback: { + fs: false, + path: false, + zlib: false, + "buffer": require.resolve("buffer") + }, }, plugins: [ new webpack.DefinePlugin({ @@ -155,6 +160,9 @@ module.exports = (env, argv, { SRC_DIR, ENTRY }) => { process.env.REACT_APP_I18N_DEBUG || '' ), }), + new webpack.ProvidePlugin({ + Buffer: ['buffer', 'Buffer'], + }), // Uncomment to generate bundle analyzer // new BundleAnalyzerPlugin(), ],