[Webpack 2] Expose modules to dependencies with Webpack
webpack to with modules Dependencies
2023-09-14 08:59:19 时间
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] Analyze a Production JavaScript Bundle with webpack-bundle-analyzer
- webpack打包生成多个vendor的配置方法
- webpack 配置热更新
- [Webpack] Externalize Dependencies to be Loaded via CDN with webpack
- [Webpack] Analyze a Production JavaScript Bundle with webpack-bundle-analyzer
- [Webpack 2] Expose modules to dependencies with Webpack
- webpack模块化原理
- Webpack基础应用篇 - [7] 资源模块
- 成功解决To fix this you could try to: 1. loosen the range of package versions you‘ve specified
- webpack 4 配置备忘
- 对webpack的理解——打包样式资源