【问题标题】:Webpack chunks are not splitting properlyWebpack 块没有正确拆分
【发布时间】:2021-04-25 04:22:45
【问题描述】:

经过多次尝试,我得出的结论是测试正则表达式有问题但无法修复。

这似乎 \.?[\\/]node_modules[\\/]((?!react-pdf)).*regex-tester 但不起作用

splitChunks: {
      chunks: 'all',
      maxInitialRequests: Infinity,
      minSize: 0,
      cacheGroups: {
        patientVendor: {
          test: /[\\/]node_modules[\\/](!react-pdf)[\\/]/,
          name: 'patientVendor',
          chunks: 'all',
        },
        reactPDFVendor: {
          test: /[\\/]node_modules[\\/](react-pdf)[\\/]/,
          name: 'reactPDFChunk',
          chunks: 'all',
        },
      },
    },
  }

预期: react-pdf的不同块 名称为 patientVendor.[hash].js 的每个其他模块的不同块

当前: react-pdf的不同块 名称为 [hash].js 的每个其他模块的不同块

【问题讨论】:

    标签: webpack webpack-4


    【解决方案1】:

    下面的正则表达式解决了这个问题,我也没有明确想要一个 pdf-js 的命名包

    splitChunks: {
          cacheGroups: {
            vendor: {
              // just need to exclude these they will created by webpack as other chunk
              test: /.?[\\/]node_modules[\\/](?!(react-pdf|pdfjs-dist)).*?/,
              name: 'patientVendors',
              chunks: 'all',
            },
          },
        },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-24
      • 1970-01-01
      • 1970-01-01
      • 2018-11-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-05
      相关资源
      最近更新 更多