vue.config.js 2.1 KB

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