遵循webpack 4.x documentation,我们可以使用IgnorePlugin()方法忽略插件,但下面的示例只忽略一个模块(moment/locales)
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/
});如果我想忽略另一个模块(例如:react-tooltip/dist/index.es.js),有没有办法通过传递一个带有resourceRegExp或contextRegExp的数组来实现另一个要忽略的模块呢?
我试过了:
new webpack.IgnorePlugin(/^\.\/index\.es\.js$/, /react-tooltip\/dist$/),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),但是这个文件似乎总是存在于包中
发布于 2021-08-21 01:12:02
您可以尝试在regex中匹配多个模块
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/(locale|index\.es\.js)$/,
contextRegExp: /(moment$|react-tooltip\/dist$)/
});这将在moment和react-tooltip/dist中匹配locale和index.es.js,这不是理想的解决方案,但可能已经足够好了。
https://stackoverflow.com/questions/65004054
复制相似问题