Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack combine multiple version of jquery to reduce file size

I have used multiple node_modules in my project those are dependent on jquery such as materialize, jquery-validation etc.

I used webpack to build a single file so i can reduce number of request. All the dependencies uses different version of jquery libraries (mainly 2.4 and 3.1) Is there any option to combine all the jquery version to single code library.

For example: if I use 3 modules it create 3 different jquery modules in my build file.

How I can convert them in to single jquery version?

like image 737
Anurag Jain Avatar asked Sep 21 '16 08:09

Anurag Jain


1 Answers

You can define in webpack's config to always resolve this dependency from certain location:

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

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

like image 86
Bartłomiej Łoszewski Avatar answered Nov 15 '22 05:11

Bartłomiej Łoszewski