Shimming预置全局变量
howcode 2022-07-18 0 webpack
# 使用场景
假如在全局中,你有个全局都要频繁使用到的插件,可以在 webpack 中进行全局注册
全局注册后,不需要任何引入操作,便可以在任意地方使用
# 配置
conts webpack = require("webpack")
module.exports = {
plugins:[
new webpack.ProvidePlugin({
$:'jquery',
_join:['lodash','join']
})
]
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
- 在模块中有使用$符的,那么就会和jquery库对应起来,实际就是把jquery在该模块中引入,并命名$符
- _join 是和 lodash 库中的 join 方法相关联
评论
- 表情
——暂无评论——