import path from "path";
import UnoCSS from "unocss/vite";
import { presetUno } from "@unocss/preset-uno";

//调用vite手动build的自定义配置
export const customConfig = {
  resolve: {
    alias: {
      "@mobileUI": path.resolve(__dirname, "../../src"),
    },
  },
  css: {
    //css预处理
    preprocessorOptions: {
      scss: {
        charset: false,
        additionalData: `@import "../../../common/scss/output.scss";`,
      },
    },
    postcss: {
      plugins: [
        {
          postcssPlugin: "internal:charset-removal",
          AtRule: {
            charset: (atRule) => {
              if (atRule.name === "charset") {
                atRule.remove();
              }
            },
          },
        },
      ],
    },
  },
  plugins: [
    // UnoCSS({
    //   presets: [presetUno()],
    // }),
    // vue(),
    // Components({
    //   resolvers: [],
    // }),
  ],
};

// vite中的build的配置
export const rollupOptions = {
  external: ["vue", "vant", "vue-router", "vuedraggable", "dayjs", "qs"],
  output: {
    exports: "named",
    globals: {
      vue: "Vue",
      vant: "vant",
    },
  },
};
