I'm using npm together with Browserify to package all my libraries/plugins.
Everything is working fine except for select2. I've tried all browserify-shim related fixes and nothing is making it work.
Here are how my files are currently:
package.json
"devDependencies": {
"axios": "^0.18",
"bootstrap": "^4.3.1",
"browserify-shim": "^3.8.14",
"cross-env": "^5.1",
"jquery": "^3.3.1",
"laravel-mix": "^4.0.15",
"lodash": "^4.17.11",
"popper.js": "^1.14.7"
},
"browserify": {
"transform": ["browserify-shim"]
},
"browserify-shim": {
"jquery": "$"
},
module-loads.js
/* JQuery */
global.jQuery = global.$ = require("jquery");
/* Select2 */
global.select2 = require('select2');
The settings above throw no errors whatsoever except Uncaught TypeError: $(...).select2 is not a function when attempting to initialize select2.
Any thoughts? Thanks for your attention.