Webpack integrates several versions of jquery to reduce file size

I used several node_modules in my project that depend on jquery, such as materialization, jquery-validation, etc.

I used webpack to create a single file so that I can reduce the number of requests. All dependencies use different versions of jQuery libraries (mainly 2.4 and 3.1). Is it possible to combine the entire version of jquery with a separate code library.

For example: if I use 3 modules, it creates 3 different jquery modules in my assembly file.

How can I convert them to one version of jquery?

+5
source share
1 answer

You can define in your webpack configuration to always allow this dependency from a specific location:

config.resolve = { alias: { "jquery": path.resolve(path.join(__dirname, "node_modules", "jquery")) } }; 

https://webpack.js.org/configuration/resolve/

+4
source

All Articles