-
-
Save rohit-gohri/59d0e6a9b4f51d1dd39f5e8894050f74 to your computer and use it in GitHub Desktop.
docusuarus webpack 5 plugin to provide node polyfills
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
plugins: [require.resolve('./sitePlugin')], | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | |
], | |
}; | |
}, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this did the trick for me. I just needed a few extra things:
I added
const webpack = require('webpack');
as the first line.I installed the
to-arraybuffer
NPM package.Then my build completed successfully. I really appreciate the guidance.