malihu-custom-scrollbar-plugin: Doesn't play nicely with Webpack
This library doesn’t work with Webpack without overrides. In particular, jquery-mousewheel doesn’t get required properly,
From what I can tell, this is because, jquery-mousewheel is only required when RequireJS is deemed not present.
However, in the Webpack supports both the CommonJS and AMD formats, so this prevents the import of jquery-mousewheel.
In addition require("jquery-mousewheel")($) won’t work if using Webpack, because, again, jquery-mousewheel will think we’re using AMD in this situation.
(#306 might be relevant.)
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 3
- Comments: 15 (4 by maintainers)
try to resolve this problem in webpack, i am comment some lines in mCustomSrollBar.js file.
Problem consist of that file cant find route to node_modules folder for load mousewheel file, so there is a fast solution:
Seven month left from the date the issue appeared here. Any support for Webpack?
If anyone trying to integrate mCustomScrollbar with Webpack 5 check below link, as I faced similar issue with this plugin and as per docs of this plugin, in latest webpack
module-loadershas been removed.https://stackoverflow.com/a/68558662/2370769
I’ve updated npm to include jquery.mCustomScrollbar.concat.min.js so you can use this file if you want.
I’m working on it. This is what I found so far:
At the moment I cannot remove the RequireJS condition to load mousewheel plugin because it conflicts with other module-loaders/managers. It’s best to load jquery-mousewheel separately (not automatically via jquery.mCustomScrollbar.js):
jquery-mousewheel plugin requires webpack imports-loader (install:
npm install imports-loader). This is because UMD (Universal Module Definition) for jQuery plugins conflicts with webpack (#833).Next version of custom scrollbar (3.1.5) will also have support for AMD so it’ll also require imports-loader.
After imports-loader installation, add the following in your webpack.config.js:
This way you can use
require("jquery-mousewheel")($);andrequire("malihu-custom-scrollbar-plugin")($);.On the next plugin version, I’m planning on adding in NPM the minified-concatenated plugin file which includes the mousewheel plugin. So you’ll be able to use it by adding the following in your config:
Hope this helps
I found out (while working on something else) that you need to require jquery-mousewheel following way to be loaded as CommonJS module:
require('imports?define=>false!jquery-mousewheel/jquery.mousewheel')($)You’ll need to have
imports-loaderinstalled (with npm) into your webpack to be able to do that.