vue.config.js 2.1 KB

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