您的位置:首页 > Web前端 > Webpack

[Webpack 2] Expose modules to dependencies with Webpack

2016-06-28 01:33 489 查看
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'
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: