1. 程式人生 > 其它 >配置生產環境加路徑 /開發環境

配置生產環境加路徑 /開發環境

技術標籤:vue

let proxyObj = {};
const CompressionPlugin = require("compression-webpack-plugin");
proxyObj['/'] = {
    ws: false,
    target: 'http://192.168.10.110:8082',
    //target: 'http://localhost:8082',
    changeOrigin: true,
    pathRewrite: {
        '^/': ''
    }
}
module.exports = {
    //生產環境加路徑
    publicPath: '/finance',
    outputDir: 'dist',
    //assetsDir: 'static',
    lintOnSave: process.env.NODE_ENV === 'development',
    devServer: {
        host: 'localhost',
        port: 8080,
        proxy: proxyObj
    },
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            return {
                plugins: [
                    new CompressionPlugin({
                        test: /\.js$|\.html$|\.css/,
                        threshold: 1024,
                        deleteOriginalAssets: false
                    })
                ]
            }
        }
    }
}

VUE_APP_BASE_API = ''