首页 > Web开发 > 详细

[Webpack 2] Expose modules to dependencies with Webpack

时间:2016-06-28 02:02:01      阅读:308      评论:0      收藏:0      [点我收藏+]

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!