1012414140@qq.com
2026-10-16 49345844dc953732e015889d58ea73b2bc7adef9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var path = require('path')
module.exports = {
  publicPath: '/',
  assetsDir: 'static',
  productionSourceMap: false, // 关闭sourceMap,减少产物体积
 
  configureWebpack: {
    optimization: {
      minimizer: [
        new (require('terser-webpack-plugin'))({
          terserOptions: {
            compress: {
              drop_console: true, // 移除console
              drop_debugger: true, // 移除debugger
              pure_funcs: ['console.log'] // 彻底清理日志函数
            },
            output: {
              comments: false // 移除所有注释
            }
          },
          extractComments: false // 不单独提取注释文件
        })
      ],
 
      // ========== 重构分包规则(核心修复包变大问题) ==========
      // 单独抽离运行时代码,所有分包共用,减少冗余
      runtimeChunk: 'single',
 
      splitChunks: {
        chunks: 'all', // 同步+异步chunk都拆分
        minSize: 20 * 1024, // 最小拆分体积:20kb,小于这个大小不拆包
        minChunks: 2, // 模块至少被引用2次才抽离为公共包
        maxAsyncRequests: 30,
        maxInitialRequests: 30,
        name: false, // 关闭自动命名
 
        cacheGroups: {
          // 业务公共代码(多个页面共用的业务JS)
          common: {
            name: 'common',
            chunks: 'all',
            minChunks: 2,
            priority: 5,
            reuseExistingChunk: true // 复用已存在的chunk
          },
 
          // 第三方依赖 node_modules(核心vendor分包)
          vendor: {
            test: /[\\/]node_modules[\\/]/,
            name: 'vendor',
            chunks: 'all',
            priority: 10,
            reuseExistingChunk: true
          }
        }
      }
      // ======================================================
    },
    resolve: {
      alias: {
        '@': path.join(__dirname, 'src')
      }
    }
  },
 
  devServer: {
    sockHost: 'localhost',
    port: 8082,
    disableHostCheck: true,
    proxy: {
      '/': {
        // target: 'http://183.196.93.178:39999',
        target: 'http://192.168.0.147:8089',
        changeOrigin: true,
        pathRewrite: {
          '/': ''
        }
      }
    }
  }
}