vue.config.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. const { defineConfig } = require('@vue/cli-service')
  2. module.exports = defineConfig({
  3. transpileDependencies: true,
  4. lintOnSave: false,
  5. productionSourceMap: false,
  6. devServer: {
  7. port: 8080,
  8. open: true,
  9. proxy: {
  10. '/auth': {
  11. target: process.env.VUE_APP_BASE_API,
  12. changeOrigin: true,
  13. pathRewrite: { '^/auth': '/auth' }
  14. },
  15. '/laboratory': {
  16. target: process.env.VUE_APP_BASE_API,
  17. changeOrigin: true,
  18. pathRewrite: { '^/laboratory': '/laboratory' }
  19. }
  20. }
  21. },
  22. css: {
  23. loaderOptions: {
  24. sass: {
  25. additionalData: `@import "@/styles/variables.scss";`
  26. }
  27. }
  28. },
  29. chainWebpack(config) {
  30. // 页面标题
  31. config.plugin('html').tap(args => {
  32. args[0].title = process.env.VUE_APP_TITLE || '实验室安全智慧化管控中心'
  33. return args
  34. })
  35. },
  36. configureWebpack: {
  37. optimization: {
  38. splitChunks: {
  39. chunks: 'all',
  40. cacheGroups: {
  41. // Vue 全家桶
  42. vue: {
  43. name: 'chunk-vue',
  44. test: /[\\/]node_modules[\\/](vue|vue-router|vuex)[\\/]/,
  45. priority: 30
  46. },
  47. // ECharts 单独拆包(体积最大)
  48. echarts: {
  49. name: 'chunk-echarts',
  50. test: /[\\/]node_modules[\\/](echarts|zrender)[\\/]/,
  51. priority: 25
  52. },
  53. // Element UI
  54. elementUI: {
  55. name: 'chunk-element-ui',
  56. test: /[\\/]node_modules[\\/]element-ui[\\/]/,
  57. priority: 20
  58. },
  59. // 其余第三方
  60. vendors: {
  61. name: 'chunk-vendors',
  62. test: /[\\/]node_modules[\\/]/,
  63. priority: 10,
  64. reuseExistingChunk: true
  65. }
  66. }
  67. }
  68. }
  69. }
  70. })