loulijun2021
2022-12-31 b012ab3a1e5495be068c543eb8f0482124db13b5
vue.config.js
@@ -2,6 +2,7 @@
const path = require('path')
const defaultSettings = require('./src/settings.js')
const webpack = require('webpack')
function resolve(dir) {
  return path.join(__dirname, dir)
}
@@ -40,6 +41,7 @@
  //     }
  //   }
  // },
  transpileDependencies: ['screenfull'],
  productionSourceMap: false,
  devServer: {
    port: port,
@@ -50,11 +52,14 @@
    },
    proxy: {
      [process.env.VUE_APP_BASE_API]: {
        target: 'http://121.196.36.24:8001', // 请求的第三⽅接⼝地址
        changeOrigin: true, // 请求跨域时,需配置此项
        target: 'http://121.196.36.24:8001', // 请求的第三⽅接⼝地址       本地开发服务器
        // target: 'http://192.168.2.138:8001', // 请求的第三⽅接⼝地址   客户服务器(大岛)
        // target: 'http://192.168.5.176:8001', // 请求的第三⽅接⼝地址   客户服务器(普登)
        changeOrigin: true, // 请求跨域时,需 配置此项
        pathRewrite: { // 路径重写,替换target中的请求地址
          ['^' + process.env.VUE_APP_BASE_API]: '/api/'
        }
        // ws: true;//开启ws, 如果是http代理此处可以不用设置
      }
    }
    // before: require('./mock/mock-server.js')
@@ -73,7 +78,15 @@
        jQuery: 'jquery',
        $: 'jquery'
      })
    ]
    ],
    // module: {
      // rules: [
      //   {
      //     test: /.vue$/,
      //     loader: 'vue-loader'
      //   }
      // ]
    // }
  },
  chainWebpack(config) {
    // it can improve the speed of the first screen, it is recommended to turn on preload
@@ -114,34 +127,34 @@
            .plugin('ScriptExtHtmlWebpackPlugin')
            .after('html')
            .use('script-ext-html-webpack-plugin', [{
            // `runtime` must same as runtimeChunk name. default is `runtime`
              // `runtime` must same as runtimeChunk name. default is `runtime`
              inline: /runtime\..*\.js$/
            }])
            .end()
          config
            .optimization.splitChunks({
              chunks: 'all',
              cacheGroups: {
                libs: {
                  name: 'chunk-libs',
                  test: /[\\/]node_modules[\\/]/,
                  priority: 10,
                  chunks: 'initial' // only package third parties that are initially dependent
                },
                elementUI: {
                  name: 'chunk-elementUI', // split elementUI into a single package
                  priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
                  test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
                },
                commons: {
                  name: 'chunk-commons',
                  test: resolve('src/components'), // can customize your rules
                  minChunks: 3, //  minimum common number
                  priority: 5,
                  reuseExistingChunk: true
                }
            chunks: 'all',
            cacheGroups: {
              libs: {
                name: 'chunk-libs',
                test: /[\\/]node_modules[\\/]/,
                priority: 10,
                chunks: 'initial' // only package third parties that are initially dependent
              },
              elementUI: {
                name: 'chunk-elementUI', // split elementUI into a single package
                priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
                test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
              },
              commons: {
                name: 'chunk-commons',
                test: resolve('src/components'), // can customize your rules
                minChunks: 3, //  minimum common number
                priority: 5,
                reuseExistingChunk: true
              }
            })
            }
          })
          // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
          config.optimization.runtimeChunk('single')
        }