标签:
When you have a dependency that has dependencies on global variables (like jQuery or lodash) or assumes that this
is bound to window
, you can use the imports-loaderto provide those dependencies explicitly.
In case there is one dependency that we use need lodash, but didn‘t includes lodash as dependency.
One way to solve the problem is that we can include lodash as denpedency in our application.
Another way is expose lodash to that library, to do that, you need to Install:
npm i -D imports-loader
Add to webpack config:
{ test: require.resolve(‘./src/js/non_node_modules/sweet-lodash-mixins‘), loader: ‘imports?_=lodash‘ }
[Webpack 2] Expose modules to dependencies with Webpack
标签:
原文地址:http://www.cnblogs.com/Answer1215/p/5622054.html