【问题标题】:Splitting chunks - problem with regex (js)?拆分块 - 正则表达式(js)的问题?
【发布时间】:2018-11-17 18:51:19
【问题描述】:

我正在尝试将我的构建文件拆分到我的webpack.config.js 文件中,但我的vendors 文件根本没有被创建。其余的node_modules,不是reactmoment 文件最终在main.js 中。 main.js 中的文件示例是 ./node_modules/es-abstract。我将我的正则表达式和文件名放入正则表达式检查器中,它通过了测试。我不确定发生了什么;任何帮助将不胜感激。

splitChunks: {
      cacheGroups: {
        moment: {
          test: /[\\/]node_modules[\\/]((moment).*)[\\/]/,
          name: 'moment',
          chunks: 'all'
        },
        react: {
          test: /[\\/]node_modules[\\/]((react).*)[\\/]/,
          name: 'react',
          chunks: 'all'
        },
        vendors: { 
          test: /[\\/]node_modules[\\/]((?!(moment|react)).*)[\\/]/, 
          name: 'vendors', 
          chunks: 'all' 
        }
      }
    }

【问题讨论】:

    标签: regex reactjs webpack webpack-splitchunks splitchunksplugin


    【解决方案1】:

    根据David Gilbertson,SplitChunks 默认设置只允许三个块。为了解决这个问题,需要将这些设置添加到拆分块中:maxInitialRequests: Infinity, minSize: 0,

    【讨论】:

      猜你喜欢
      • 2011-04-03
      • 1970-01-01
      • 2011-06-29
      • 2017-04-30
      • 1970-01-01
      • 2012-11-23
      • 1970-01-01
      • 2020-03-24
      • 1970-01-01
      相关资源
      最近更新 更多