const CompressionWebpackPlugin = require("compression-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const MomentLocalesPlugin = require("moment-locales-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/",
        target: "http://183.134.99.140:9901/",
        pathRewrite: {
          "^/yccApi": "",
        },
        changeOrigin: true,
      },
      "/market": {
        target: "http://18.181.228.127:8072/api/ticker",
        pathRewrite: {
          "^/market": "",
        },
      },
      "/expandApi": {
        // target: "http://121.37.141.165:19992/ycc",
        target: "http://183.134.99.140:19993/pos33",
        pathRewrite: {
          "^/expandApi": "",
        },
        changeOrigin: true,
      },
      "/setScan": {
        target: "http://116.63.166.13:5333",
        pathRewrite: {
          "^/setScan": "",
        },
        changeOrigin: true,
      },
    },
  },
  configureWebpack: {
    plugins: [
      new CompressionWebpackPlugin({
        algorithm: "gzip",
        threshold: 10240,
        minRatio: 0.8,
      }),
      new MomentLocalesPlugin({
        localesToKeep: ["zh-cn"],
      }),
    ],
  },
  // 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()
  // }
};
