const CompressionWebpackPlugin = require("compression-webpack-plugin")
const TerserPlugin = require("terser-webpack-plugin")

module.exports = {
  outputDir: 'dist',
  publicPath: './',
  devServer: {
    proxy: { // 设置代理
      '/api': {
        target: 'https://public.zhaobi.tech/web/api',
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      },
      "/coin": {
        target: "https://b.biqianbao.net/",
        pathRewrite: {
          "^/coin": ""
        },
        changeOrigin: true,
      },
      "/yccApi": {
        // target: "https://mainnet.yuan.org/api",
        target: "http://13.115.171.240:7901/",
        pathRewrite: {
          "^/yccApi": ""
        },
        changeOrigin: true,
      },
    }
  },
  configureWebpack: {
    plugins: [
      new CompressionWebpackPlugin({
        algorithm: "gzip",
        threshold: 10240,
        minRatio: 0.8,
      }),
    ],
  },
  // chainWebpack: config => {
  //   config.module
  //     .rule('min-image')
  //     .test(/\.(png|jpe?g|gif)(\?.*)?$/)
  //     .use('image-webpack-loader')
  //     .loader('image-webpack-loader')
  //     .options({ disable: process.env.NODE_ENV == 'development' ? true : false })//此处为ture的时候不会启用压缩处理,目的是为了开发模式下调试速度更快,网上错误示例直接写为disable:true,如果不去查看文档肯定是要被坑的
  //     .end()
  // }
}
