Skip to content

Instantly share code, notes, and snippets.

@rohit-gohri
Forked from sibelius/docusaurus.config.js
Last active November 19, 2021 16:05
Show Gist options
  • Save rohit-gohri/59d0e6a9b4f51d1dd39f5e8894050f74 to your computer and use it in GitHub Desktop.
Save rohit-gohri/59d0e6a9b4f51d1dd39f5e8894050f74 to your computer and use it in GitHub Desktop.
docusuarus webpack 5 plugin to provide node polyfills
module.exports = {
plugins: [require.resolve('./sitePlugin')],
}
const webpack = require('webpack');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
module.exports = function (context, options) {
return {
name: 'custom-docusaurus-webpack-config-plugin',
configureWebpack(config, isServer, utils) {
return {
resolve: {
fallback: {
fs: false,
},
},
plugins: [
new webpack.DefinePlugin({
"process.versions.node": JSON.stringify(process.versions.node || "0.0.0"),
}),
new NodePolyfillPlugin(),
],
};
},
};
};
@pglezen
Copy link

pglezen commented Nov 19, 2021

Thanks, this did the trick for me. I just needed a few extra things:

  1. I added const webpack = require('webpack'); as the first line.

  2. I installed the to-arraybuffer NPM package.

Then my build completed successfully. I really appreciate the guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment