vue.config.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. const CompressionPlugin = require("compression-webpack-plugin");
  2. const webpack = require("webpack");
  3. const BundleAnalyzerPlugin =
  4. require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
  5. module.exports = {
  6. publicPath: process.env.NODE_ENV === "production" ? "" : "/",
  7. productionSourceMap: false,
  8. lintOnSave: false,
  9. chainWebpack: (config) => {
  10. if (process.env.NODE_ENV === "production") {
  11. if (process.env.npm_config_report) {
  12. config
  13. .plugin("webpack-bundle-analyzer")
  14. .use(
  15. require("webpack-bundle-analyzer").BundleAnalyzerPlugin
  16. );
  17. }
  18. config.plugins.delete("prefetch");
  19. }
  20. },
  21. configureWebpack: (config) => {
  22. if (process.env.NODE_ENV === "production") {
  23. config.optimization = {
  24. splitChunks: {
  25. chunks: "all", //async异步代码分割 initial同步代码分割 all同步异步分割都开启
  26. minSize: 10000, //字节 引入的文件大于30kb才进行分割
  27. // minChunks: 2, //模块至少使用次数
  28. // maxAsyncRequests: 25, //同时加载的模块数量最多是5个,只分割出同时引入的前5个文件
  29. // maxInitialRequests: 30, //首页加载的时候引入的文件最多3个
  30. automaticNameDelimiter: "-", //缓存组和生成文件名称之间的连接符
  31. // name: true, //缓存组里面的filename生效,覆盖默认命名
  32. cacheGroups: {
  33. // vue: {
  34. // name: "vue",
  35. // test: /[\\/]node_modules[\\/]vue[\\/]/,
  36. // test: /[\\/]node_modules[\\/]vue[\\/]/,
  37. // priority: -10
  38. // },
  39. // vuex: {
  40. // name: 'vuex',
  41. // test: /[\\/]node_modules[\\/]vuex[\\/]/,
  42. // priority: -10qa
  43. // },
  44. // 'vue-router': {
  45. // name: 'vue-router',
  46. // test: /[\\/]node_modules[\\/]vue-router[\\/]/,
  47. // priority: -10
  48. // },
  49. // 'element-ui': {
  50. // name: 'element-ui',
  51. // test: /[\\/]node_modules[\\/]element-ui[\\/]/,
  52. // priority: -10
  53. // },
  54. // vendors: {
  55. // test: /[\\\/]node_modules[\\\/]/,
  56. // priority: -20
  57. // },
  58. },
  59. },
  60. };
  61. // return {
  62. // plugins: [
  63. // new CompressionPlugin({
  64. // test: /\.js$|\.html$|\.css$/,
  65. // threshold: 10240,
  66. // deleteOriginalAssets: false,
  67. // }),
  68. // new webpack.optimize.MinChunkSizePlugin({
  69. // minChunkSize: 10000 // Minimum number of characters
  70. // }),
  71. // new WebpackLifeCyclePlugin(),
  72. // new BundleAnalyzerPlugin()
  73. // ]
  74. // }
  75. // config.plugins = [
  76. // new CompressionPlugin({
  77. // test: /\.js$|\.html$|\.css$/,
  78. // threshold: 10240,
  79. // deleteOriginalAssets: true,
  80. // }),
  81. // new webpack.optimize.MinChunkSizePlugin({
  82. // minChunkSize: 10000 // Minimum number of characters
  83. // }),
  84. // new WebpackLifeCyclePlugin(),
  85. // // new BundleAnalyzerPlugin()
  86. // ]
  87. }
  88. },
  89. parallel: true,
  90. devServer: {
  91. proxy: {
  92. // 开发环境变化可注释 ⬇️⬇️
  93. "/market/CMK": {
  94. <<<<<<< HEAD
  95. target: "http://43.138.50.94:9600",
  96. =======
  97. target: "http://192.168.2.124:9113",
  98. >>>>>>> 994fc041f082ba5e33229f3e58f7c4b6c7b355c4
  99. ws: false,
  100. changeOrigin: true,
  101. pathRewrite: {
  102. "^/market": "",
  103. },
  104. },
  105. "/market/mk": {
  106. <<<<<<< HEAD
  107. target: "http://43.138.50.94:9600",
  108. =======
  109. target: "http://192.168.2.124:9113",
  110. >>>>>>> 994fc041f082ba5e33229f3e58f7c4b6c7b355c4
  111. ws: false,
  112. changeOrigin: true,
  113. pathRewrite: {
  114. "^/market": "",
  115. },
  116. },
  117. "/market/techcentergj": {
  118. <<<<<<< HEAD
  119. target: "http://43.138.50.94:9600",
  120. =======
  121. target: "http://192.168.2.124:9113",
  122. >>>>>>> 994fc041f082ba5e33229f3e58f7c4b6c7b355c4
  123. ws: false,
  124. changeOrigin: true,
  125. pathRewrite: {
  126. "^/market": "",
  127. },
  128. },
  129. "/mkWangge": {
  130. target: "http://192.168.2.124:9113",
  131. ws: false,
  132. changeOrigin: true,
  133. pathRewrite: {
  134. "^/market": "",
  135. },
  136. },
  137. "/api": {
  138. target: "http://43.138.50.94:7777",
  139. ws: false,
  140. changeOrigin: true,
  141. pathRewrite: {
  142. "^/api": "",
  143. },
  144. },
  145. // 开发环境变化可注释 ⬆️⬆️
  146. "/": {
  147. // target: 'http://192.168.2.145:9600/spfm',
  148. // target: 'http://192.168.2.149:9600',
  149. // target: 'http://10.64.42.70:8088/',
  150. // target: 'http://114.215.71.182:29600',
  151. // target: 'http://192.168.1.9:9600/spfm',
  152. // target: 'http://127.0.0.1:9600/',
  153. // target: 'http://192.168.0.156:9600/',
  154. // target: 'http://192.168.2.44:9600/',
  155. target: 'http://192.168.2.124:9600/',
  156. // target: "http://124.223.66.248:9600",
  157. // target: "http://43.138.50.94:9600",
  158. changeOrigin: true,
  159. },
  160. },
  161. },
  162. transpileDependencies: ["color-string"], // 此段为增加配置选项
  163. };