vue.config.js 2.1 KB

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