我正在查看包含以下代码的 webpack 配置:
new webpack.ProvidePlugin({
fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
}),
我从webpack 文档中看到,ProvidePlugin
它用右侧的模块替换左侧的值(获取),而无需任何import
必要。
我可以按照文档中的示例进行操作,例如
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
在代码中遇到$
或遇到的任何地方加载到 jquery 模块中。jQuery
但是我的代码看起来不像是一个js模块,那么它在做什么呢?