vue.config.js 6.1 KB

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