vue.config.js 1.6 KB

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