Skip to content

Instantly share code, notes, and snippets.

@ecklf
Created December 11, 2020 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecklf/207d0b3e062fcd97b50484e54210685e to your computer and use it in GitHub Desktop.
Save ecklf/207d0b3e062fcd97b50484e54210685e to your computer and use it in GitHub Desktop.
lodash-webpack-plugin webpack 5 patch
diff --git a/node_modules/lodash-webpack-plugin/lib/index.js b/node_modules/lodash-webpack-plugin/lib/index.js
index d791223..2aca193 100644
--- a/node_modules/lodash-webpack-plugin/lib/index.js
+++ b/node_modules/lodash-webpack-plugin/lib/index.js
@@ -84,13 +84,17 @@ function () {
/* Webpack >= 4 */
if (compiler.hooks) {
+ const webpackVersion = parseInt(require('webpack/package.json').version, 10)
+
compiler.hooks.normalModuleFactory.tap('LodashModuleReplacementPlugin', function (nmf) {
nmf.hooks.afterResolve.tap('LodashModuleReplacementPlugin', function (data) {
if (data) {
data.resource = resolve(data);
}
- return data;
+ if (webpackVersion < 5) {
+ return data
+ }
});
});
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment