I have something like this in my webpack config:
plugins:[
new webpack.ProvidePlugin({ THREE: 'three' }),
...
which makes THREE available globally (or at least wherever its used?)
I would like to override a method from this library, for example in the entry point:
THREE.Something = mySomething;
I'm not succeding, how is this done?
Alternatively i tried something like.
require(expose?THREE!./myCustomThree.js);
But that didnt work either, i only got it in the scope where i made the require call. I was able to override the method though, but can't make it global.
ProvidePlugin just replaces globally the string provided with the instance of the module defined.
new webpack.ProvidePlugin({
'$': 'jquery',
'$.each': 'moment'
})
The above plugin now replaces all instances of $
in your code with the instance of jquery. And in the second case, it replaces $.moment
with the instance of moment.
You have to understand that ProvidePlugin simply renames the module to the string you provide and I guess that is kind of an override.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.