overriding a method on a global module in webpack

前端 未结 1 1998
情深已故
情深已故 2021-01-28 22:39

I have something like this in my webpack config:

plugins:[
  new webpack.ProvidePlugin({ THREE: \'three\' }),
  ...

which makes THREE available

相关标签:
1条回答
  • 2021-01-28 23:07

    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.

    0 讨论(0)
提交回复
热议问题