index.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const rely = require('./rely')
  2. const { resolve } = require('path')
  3. module.exports = {
  4. createOptimization: (config) => {
  5. process.env['VUE_AP' + 'P_RELY'] = rely
  6. config.performance.set('hints', false)
  7. config.optimization.splitChunks({
  8. automaticNameDelimiter: '-',
  9. chunks: 'all',
  10. cacheGroups: {
  11. chunk: {
  12. name: 'vab-chunk',
  13. test: /[\\/]node_modules[\\/]/,
  14. minSize: 131072,
  15. maxSize: 524288,
  16. chunks: 'async',
  17. minChunks: 2,
  18. priority: 10,
  19. },
  20. vue: {
  21. name: 'vue',
  22. test: /[\\/]node_modules[\\/](vue(.*)|core-js)[\\/]/,
  23. chunks: 'initial',
  24. priority: 20,
  25. },
  26. elementUI: {
  27. name: 'element-plus',
  28. test: /[\\/]node_modules[\\/]element-plus(.*)[\\/]/,
  29. priority: 30,
  30. },
  31. extra: {
  32. name: 'vab-plugins',
  33. test: resolve('src/plugins'),
  34. priority: 40,
  35. },
  36. // 根据使用模块抽取公共代码
  37. // echarts: {
  38. // name: 'echarts',
  39. // test: /[\\/]node_modules[\\/](echarts|zrender|tslib)[\\/]/,
  40. // priority: 50,
  41. // },
  42. },
  43. })
  44. },
  45. }