[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
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:
Add to webpack config:
thisis 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 常用命令总结
- (三)webpack入门——webpack功能集合的demo
- [Webpack 2] Import a non-ES6 module with Webpack
- webpack configuration
- [Webpack 2] Grouping vendor files with the Webpack CommonsChunkPlugin
- [Webpack 2] Hashing with Webpack for long term caching
- [Webpack 2] Polyfill Promises for Webpack 2
- [Webpack 2] Tree shaking with Webpack 2
- [Webpack 2] Validate your Webpack config with webpack-validator
- (二)webpack入门——webpack的使用
- (一)webpack入门——webpack的安装
- Grunt、gulp、webpack、不要听着高大上你就上,试试Codekit?
- webpack
- [Webpack 2] Intro to the Production Webpack Course
- [转]webpack 使用优化指南
- webpack 多entry 配置
- webpack打包压缩工具的使用方法
- webpack es6支持配置
- webPack 使用方便快捷
- webpack loader 列表