kongdeqiang
8 小时以前 838ab86d918a219b7ab569804e63107582068164
vue.config.js
@@ -1,16 +1,55 @@
var path = require("path")
module.exports = {
    baseUrl: './',
    configureWebpack: {
        optimization: {
            minimizer: [
                new (require('terser-webpack-plugin'))({
                    terserOptions: {
                        compress: {
                            drop_console: true, // 删除生产环境console.log
                            drop_debugger: true, // 删除debugger
                        }
                    }
                })
            ]
        },
        resolve: {
            alias: {
                '@': path.join(__dirname, 'src')
            }
        }
    },
    assetsDir: 'static',
    productionSourceMap: false,
    devServer: {
        sockHost: 'localhost',
        port: 8082,
        disableHostCheck: true,
        proxy: {
            '/api':{
                target:'http://192.168.0.146',
            '/':{
                target:'http://183.196.93.178:8089',
                //target:'http://127.0.0.1:8089',
                changeOrigin:true,
                pathRewrite:{
                    '/api':''
                    '/':''
                }
            }
        }
    },
    chainWebpack : config => {
        // 图片压缩(需要安装image-webpack-loader:npm install image-webpack-loader -D)
        config.module
            .rule('images')
            .use('image-webpack-loader')
            .loader('image-webpack-loader')
            .options({
                mozjpeg: { progressive: true, quality: 65 },
                optipng: { enabled: false },
                pngquant: { quality: [0.65, 0.9], speed: 4 },
                gifsicle: { interlaced: false },
                webp: { quality: 75 } // WebP压缩质量
            })
            .end();
    }
}
}