vue.config.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. 'use strict'
  2. const path = require('path')
  3. function resolve(dir) {
  4. return path.join(__dirname, dir)
  5. }
  6. const name = '重卡换电智能站控系统'
  7. module.exports = {
  8. publicPath: "/",
  9. outputDir: 'dist',
  10. assetsDir: 'static',
  11. lintOnSave: false,
  12. productionSourceMap: false,
  13. devServer: {
  14. host: 'localhost',
  15. port: 808,
  16. open: true,
  17. overlay: {
  18. warning: false,
  19. error: true,
  20. },
  21. proxy: {
  22. '/api': {
  23. target: `http://172.16.121.248:8080`,
  24. // target: `http://172.16.12.146:8080`,
  25. ws: true,
  26. changeOrigin: true,
  27. },
  28. '/ws': {
  29. target: `ws://172.16.121.248:8080/ws`,
  30. // target: `ws://172.16.12.146:8080/ws`,
  31. ws: true,
  32. changeOrigin: true,
  33. },
  34. '/video':{
  35. target: `ws://192.168.3.177:8082/`,
  36. // target: `ws://172.16.12.146:8080/ws`,
  37. ws: true,
  38. changeOrigin: true,
  39. }
  40. },
  41. },
  42. configureWebpack: {
  43. name: name,
  44. resolve: {
  45. alias: {
  46. '@': resolve('src')
  47. }
  48. }
  49. },
  50. chainWebpack(config) {
  51. config.plugin('preload').tap(() => [
  52. {
  53. rel: 'preload',
  54. fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
  55. include: 'initial'
  56. }
  57. ])
  58. config.plugins.delete('prefetch')
  59. config.module
  60. .rule('svg')
  61. .exclude.add(resolve('src/icons'))
  62. .end()
  63. config.module
  64. .rule('icons')
  65. .test(/\.svg$/)
  66. .include.add(resolve('src/icons'))
  67. .end()
  68. .use('svg-sprite-loader')
  69. .loader('svg-sprite-loader')
  70. .options({
  71. symbolId: 'icon-[name]'
  72. })
  73. .end()
  74. config
  75. .when(process.env.NODE_ENV !== 'development',
  76. config => {
  77. config
  78. .plugin('ScriptExtHtmlWebpackPlugin')
  79. .after('html')
  80. .use('script-ext-html-webpack-plugin', [{
  81. inline: /runtime\..*\.js$/
  82. }])
  83. .end()
  84. config
  85. .optimization.splitChunks({
  86. chunks: 'all',
  87. cacheGroups: {
  88. libs: {
  89. name: 'chunk-libs',
  90. test: /[\\/]node_modules[\\/]/,
  91. priority: 10,
  92. chunks: 'initial'
  93. },
  94. elementUI: {
  95. name: 'chunk-elementUI',
  96. priority: 20,
  97. test: /[\\/]node_modules[\\/]_?element-ui(.*)/
  98. },
  99. commons: {
  100. name: 'chunk-commons',
  101. test: resolve('src/components'),
  102. minChunks: 3,
  103. priority: 5,
  104. reuseExistingChunk: true
  105. }
  106. }
  107. })
  108. config.optimization.runtimeChunk('single')
  109. }
  110. )
  111. }
  112. }