vue.config.js 6.4 KB

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