regex - 正则表达式从 node_modules 中排除文件夹
问题描述
我目前正在使用 webpack 并运行一个通过 node_modules 并排除一个特定模块的测试。
但是,当我在正则表达式检查器上尝试它时,我正在努力使用正则表达式,它工作正常。但是,在 webpack 上它失败了。
示例:https ://regex101.com/r/rO4jD0/34
^node_modules\/(?!example).*
在 webpack 本身上,我正在写以下内容:
vendor: {
test: /^[\\/]node_modules[\\/](?!example).*[\\/]/,
// test: /^[\\/]node_modules[\\/](?!example)[\\/].*/,
// test: /^node_modules\/(?!example).*/,
name: 'vendor',
chunks: 'all',
}
这些测试是我迄今为止运行的测试的示例,但不幸的是它们都失败了。
作为一个仅供参考- 这工作正常,但它不排除一个示例文件夹。
test: /[\\/]node_modules[\\/]/,
解决方案
这是要将大型供应商模块拆分为自己的捆绑包吗?我是这样做的:
vendor: {
name: 'vendor',
test: /[\\/]node_modules[\\/]((?!(example.js|slick-carousel)).*)[\\/]/,
name: 'vendors',
chunks: 'all'
},
v_example: {
test: /[\\/]node_modules[\\/]((example.js).*)[\\/]/,
name: 'v_example',
chunks: 'all'
},
v_slick: {
test: /[\\/]node_modules[\\/]((slick-carousel).*)[\\/]/,
name: 'v_slick',
chunks: 'all'
}
推荐阅读
- c++ - C++ 中有没有办法实现适用于多级函数调用的协程?
- r - R gganimate transition_time() 函数
- r - shiny:renderUI 和 shiny:uioutput 生成一个新的 menuItem 和一个新的输出,但 tabItem 没有显示
- r - 函数中奇怪的 glm() 行为
- php - 获取显示为 Null 的请求表单数据
- python - 为什么我不能选择这个?- 硒
- python - 有没有办法在函数内部调用函数
- sonarqube - Sonarqube 无法上传报告 413
- python - 表单错误不显示在模板上
- r - ggplot2 重新排序以分钟为单位的数据:秒格式