webpack 打包分包

注意点

  1. priority 优先级,数字越大越优先
    // 打包时候切分node_module三方包,以及common公用包
    splitChunks: {
      maxInitialRequests: 10,
      cacheGroups: {
        expressioneditor: {
          test: /[\\/]expression-editor|codemirror[\\/]/,
          name: 'expressioneditor',
          minSize: 30000,
          minChunks: 1,
          chunks: 'initial',
          priority: 2
        },
        editormodules: {
          test: /[\\/]js-beautify|vuedraggable|sortablejs[\\/]/,
          name: 'editormodules',
          minSize: 30000,
          minChunks: 1,
          chunks: 'initial',
          priority: 2
        },
        mobilemodules: {
          test: /[\\/](vant|smui-form-library|quill)[\\/]/,
          name: 'mobilemodules',
          minSize: 30000,
          minChunks: 1,
          chunks: 'initial',
          priority: 2
        },
        southgisui: {
          test: /[\\/]southgisui[\\/]/,
          name: 'southgisui',
          minSize: 30000,
          minChunks: 1,
          chunks: 'initial',
          priority: 2
        },
        commonmodules: {
          // 将更新频繁的库统一放到business.js文件中
          test: /[\\/](btnfuncs|fpautils)[\\/]/,
          name: 'commonmodules',
          minSize: 30000,
          minChunks: 1,
          chunks: 'initial',
          priority: 2
        },
        sguiform: {
          // 将更新频繁的库统一放到business.js文件中
          test: /[\\/](sgui-form|sguifilepreview)[\\/]/,
          name: 'sguiform',
          minSize: 30000,
          minChunks: 1,
          chunks: 'initial',
          priority: 2
        },
        jqueryModule: {
          test: /[\\/]jquery[\\/]/,
          name: 'jqueryModule',
          minSize: 30000,
          minChunks: 1,
          chunks: 'initial',
          priority: 2 // 该配置项是设置处理的优先级,数值越大越优先处理
        },
        vueModule: {
          test: /[\\/](vue|vuex)[\\/]/,
          name: 'vueModule',
          minSize: 30000,
          minChunks: 1,
          chunks: 'initial',
          priority: 2 // 该配置项是设置处理的优先级,数值越大越优先处理
        },
        vendors: {
          test: /[\\/]node_modules[\\/]/,
          name: 'vendors',
          minSize: 30000,
          minChunks: 1,
          chunks: 'initial',
          priority: 1 // 该配置项是设置处理的优先级,数值越大越优先处理
        },
        commons: {
          test: /[\\/]src[\\/]common[\\/]/,
          name: 'commons',
          minSize: 30000,
          minChunks: 3,
          chunks: 'initial',
          priority: -1,
          reuseExistingChunk: true // 这个配置允许我们使用已经存在的代码块
        },
        generateFormCommon: {
          test: /[\\/]src[\\/]pages[\\/]generateForm[\\/]src[\\/]/,
          name: 'generateFormCommon',
          minSize: 30000,
          minChunks: 2,
          chunks: 'initial',
          priority: 2,
          reuseExistingChunk: true
        },
        editorFormCommon: {
          test: /[\\/]src[\\/]pages[\\/]editor[\\/]src[\\/]/,
          name: 'editorFormCommon',
          minSize: 30000,
          minChunks: 2,
          chunks: 'initial',
          priority: 2,
          reuseExistingChunk: true
        }
      }
    }
  }

你可能感兴趣的:(webpack 打包分包)