wjli
2024-04-09 542dcd62fa061525a00339011ff24246f03b820e
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
const CompressionPlugin = require('compression-webpack-plugin');
 
module.exports = {
    devServer: {
        host: '127.0.0.1',
        port: 9999,
        proxy: {
            '/xboot': {
                target: 'http://127.0.0.1:9091',  // 请求本地 需要xboot后端项目
                //target: 'http://192.168.0.162:8888',  // 请求本地 需要xboot后端项目
                //target: 'http://111.63.178.115:9091',
                ws: true,
                changeOrigin:true,
                pathRewrite:{
                    '/api':''
                }
            },
            '/foo': {
                target: '<other_url>'
            }
        },
    },
    // 打包时不生成.map文件 避免看到源码
    productionSourceMap: false,
    // 部署优化
    configureWebpack: {
        // 使用CDN
        // externals: {
        //     vue: 'Vue',
        //     'vue-i18n': 'VueI18n',
        //     axios: 'axios',
        //     'vue-router': 'VueRouter',
        //     vuex: 'Vuex',
        //     'view-design': 'iview',
        //     echarts: 'echarts',
        //     apexcharts: 'ApexCharts',
        //     'vue-apexcharts': 'VueApexCharts',
        //     xlsx: 'XLSX',
        //     dplayer: 'DPlayer',
        //     'print-js': 'printJS',
        //     html2canvas: 'html2canvas',
        //     'vue-json-pretty': 'VueJsonPretty',
        //     'vue-lazyload': 'VueLazyload',
        //     gitalk: 'Gitalk',
        //     'js-cookie': 'Cookies',
        //     wangEditor: 'wangEditor',
        //     quill: 'Quill',
        //     stompjs: 'Stomp',
        //     'sockjs-client': 'SockJS',
        //     vuedraggable: 'vuedraggable',
        //     viewerjs: 'Viewer'
        // },
        plugins: [
            // GZIP压缩
            new CompressionPlugin({
                test: /\.js$|\.html$|\.css/, // 匹配文件
                threshold: 10240 // 对超过10k文件压缩
            })
        ]
    }
}