vue首页白屏

下载 npm i compression-webpack-plugin -D
const CompressionPlugin = require("compression-webpack-plugin")
module.exports ={
    configureWebpack: () => {
        if (process.env.NODE_ENV === 'production') {
          return {
            plugins: [
              new CompressionPlugin({
                test: /\.js$|\.html$|\.css$|\.jpg$|\.jpeg$|\.png/, // 需要压缩的文件类型
                threshold: 10240, // 归档需要进行压缩的文件大小最小值,我这个是10K以上的进行压缩
                deleteOriginalAssets: false, // 是否删除原文件
                minRatio: 0.8
              })
            ]
          }
        }
    },
    lintOnSave:false,
    outputDir:'dist',
    assetsDir:'static',
    productionSourceMap:false,
    transpileDependencies: ['vuex-persist'],
    publicPath:'./' ,
    devServer:{
        open:true,
        host:'0.0.0.0',
        port:8081,
        hotOnly:false,
        proxy:{
            // https://open.weixin.qq.com
            '/api':{
                //服务器端接口地址
                target:'http://192.168.0.150:8081',
                // target:'http://h5.u2sy.cn/',
                ws:true,
                //是否跨域
                changeOrigin:true,
                pathRewrite:{
                    '^/api':''
                }
            }
        }
    }
}
posted @ 2021-05-31 14:31  zjxgdq  阅读(83)  评论(0编辑  收藏  举报