import { defineConfig, loadConfigFromFile, loadEnv } from "vite";

import Components from "unplugin-vue-components/vite";
var pxtoviewport = require("postcss-px-to-viewport");

const config = defineConfig(({ command, mode, ssrBuild }) => {
  return {
    plugins: [
      Components({
        dirs: [
          "src/h5/components",
          "src/common/components",
          "src/h5/pages/**/_components",
        ],
        resolvers: [],
        dts: "src/h5/components.d.ts",
      }),
    ],

    server: {
      port: 3333,
      proxy: {
        '/api': {
          target: 'http://www.apdmagazine.com/', //测试服务器的
          changeOrigin: true,
          ws: true,
          pathRewrite: {
            '^/api': ''
          }
        }
      }

    },
    css: {
      postcss: {
        plugins: [
          pxtoviewport({
            viewportWidth: 375,
            propList: ["*"],
            include: /\/node_modules\/vant/,
          }),
        ],
      },
    },
  };
});

export default config;
