vue.config.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. target: "http://192.168.2.124:9113",
  95. ws: false,
  96. changeOrigin: true,
  97. pathRewrite: {
  98. "^/market": "",
  99. },
  100. },
  101. "/aps": {
  102. target: "http://192.168.2.124:7779",
  103. ws: false,
  104. changeOrigin: true,
  105. logLevel:'debug',
  106. pathRewrite: {
  107. "^/aps": "/api/file",
  108. },
  109. },
  110. "/market/mk": {
  111. target: "http://192.168.2.124:9113",
  112. ws: false,
  113. changeOrigin: true,
  114. pathRewrite: {
  115. "^/market": "",
  116. },
  117. },
  118. "/market/techcentergj": {
  119. target: "http://192.168.2.124:9113",
  120. ws: false,
  121. changeOrigin: true,
  122. pathRewrite: {
  123. "^/market": "",
  124. },
  125. },
  126. "/mkWangge": {
  127. target: "http://192.168.2.124:9113",
  128. ws: false,
  129. changeOrigin: true,
  130. pathRewrite: {
  131. "^/market": "",
  132. },
  133. },
  134. // 开发环境变化可注释
  135. "/": {
  136. // target: 'http://192.168.2.145:9600/spfm',
  137. // target: 'http://192.168.2.149:9600',
  138. // target: 'http://10.64.42.70:8088/',
  139. // target: 'http://114.215.71.182:29600',
  140. // target: 'http://192.168.1.9:9600/spfm',
  141. // target: 'http://127.0.0.1:9600/',
  142. // target: 'http://192.168.0.156:9600/',
  143. // target: 'http://192.168.2.44:9600/',
  144. target: 'http://192.168.2.124:9600',
  145. // target: "http://124.223.66.248:9600",
  146. // target: "http://43.138.50.94:9600",
  147. changeOrigin: true,
  148. logLevel:'debug',
  149. pathRewrite: {
  150. "^/market": "/",
  151. },
  152. },
  153. },
  154. },
  155. transpileDependencies: ["color-string"], // 此段为增加配置选项
  156. };