// vite.config.ts
import path from "path";
import { defineConfig } from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/vite@4.3.3_@types+node@18.16.1_sass@1.62.1/node_modules/vite/dist/node/index.js";
import vue from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/@vitejs+plugin-vue@4.2.1_vite@4.3.3_vue@3.2.47/node_modules/@vitejs/plugin-vue/dist/index.mjs";
import WindiCss from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/vite-plugin-windicss@1.8.10_vite@4.3.3/node_modules/vite-plugin-windicss/dist/index.mjs";
import AutoImport from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/unplugin-auto-import@0.10.3_@vueuse+core@9.13.0_vite@4.3.3/node_modules/unplugin-auto-import/dist/vite.mjs";
import Components from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/unplugin-vue-components@0.22.12_vue@3.2.47/node_modules/unplugin-vue-components/dist/vite.mjs";
import { ElementPlusResolver } from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/unplugin-vue-components@0.22.12_vue@3.2.47/node_modules/unplugin-vue-components/dist/resolvers.mjs";
import Icons from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/unplugin-icons@0.14.15/node_modules/unplugin-icons/dist/vite.mjs";
import IconsResolver from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/unplugin-icons@0.14.15/node_modules/unplugin-icons/dist/resolver.mjs";

// plugins/vite-plugin-conditional-compile.ts
import MagicString from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/magic-string@0.26.7/node_modules/magic-string/dist/magic-string.es.mjs";
import { createFilter } from "file:///C:/Users/EDY/Desktop/work/ai-wen/cuo-ti-ben/node_modules/.pnpm/vite@4.3.3_@types+node@18.16.1_sass@1.62.1/node_modules/vite/dist/node/index.js";
var config = void 0;
var replaceMatched = (code, id) => {
  const env = config.env;
  const source = new MagicString(code, {
    filename: id
  });
  source.replace(
    /^.*?#if(n?)def\s*(\S+).*[\r\n]{1,2}([\s\S]+?)\s*.*?#endif.*?$/gm,
    /**
     * 条件替换
     * @param _ 匹配的字符串
     * @param $1 是否为 not 模式
     * @param $2 条件
     * @param $3 code
     */
    (_, $1, $2, $3) => {
      const isNot = !!$1;
      const isKeep = $2.split("||").some((v) => {
        let flag = false;
        const [key, value] = v.split("=");
        if (value === void 0)
          flag = !!env[key];
        else
          flag = String(env[key]) === value;
        flag = isNot ? !flag : flag;
        return flag;
      });
      return isKeep ? $3 : "";
    }
  );
  if (source.hasChanged()) {
    return {
      code: source.toString(),
      map: source.generateMap({
        source: id,
        file: `${id}.map`,
        includeContent: true
      })
    };
  }
};
var resolveOptions = (userOptions) => {
  return {
    include: ["**/*"],
    exclude: [],
    ...userOptions
  };
};
var VitePluginConditionalCompile = (userOptions = {}) => {
  const options = resolveOptions(userOptions);
  return {
    name: "vite-plugin-conditional-compile",
    enforce: "pre",
    configResolved(_config) {
      config = _config;
    },
    transform(code, id) {
      const filter = createFilter(options.include, options.exclude);
      if (filter(id))
        return replaceMatched(code, id);
    }
  };
};
var vite_plugin_conditional_compile_default = VitePluginConditionalCompile;

// vite.config.ts
var __vite_injected_original_dirname = "C:\\Users\\EDY\\Desktop\\work\\ai-wen\\cuo-ti-ben";
var vite_config_default = defineConfig({
  resolve: {
    alias: {
      "@": path.resolve(__vite_injected_original_dirname, "src"),
      "~": path.resolve(__vite_injected_original_dirname, "src")
      // '~components': path.resolve(__dirname, 'src/components'),
      // '~pages': path.resolve(__dirname, 'src/pages'),
      // '~utils': path.resolve(__dirname, 'src/utils'),
      // '~assets': path.resolve(__dirname, 'src/assets'),
      // '~styles': path.resolve(__dirname, 'src/styles'),
      // '~lib': path.resolve(__dirname, 'src/lib'),
      // '~plugins': path.resolve(__dirname, 'src/plugins'),
      // '~router': path.resolve(__dirname, 'src/router'),
      // '~store': path.resolve(__dirname, 'src/store'),
      // '~config': path.resolve(__dirname, 'src/config'),
      // '~api': path.resolve(__dirname, 'src/api'),
      // '~constants': path.resolve(__dirname, 'src/constants'),
      // '~locales': path.resolve(__dirname, 'src/locales'),
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@use "./element.scss" as *;'
      }
    }
  },
  plugins: [
    vite_plugin_conditional_compile_default(),
    vue({
      reactivityTransform: true
    }),
    WindiCss(),
    AutoImport({
      // dts: 'src/auto-imports.d.ts',
      imports: ["vue", "vue/macros", "vue-router"],
      dirs: [
        "src/composables",
        // 'src/store',
        "src/utils"
      ],
      resolvers: [ElementPlusResolver()],
      vueTemplate: true,
      eslintrc: {
        enabled: true
        // enabled: false, // Default `false`
        // filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
        // globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
      }
    }),
    Components({
      // dts: 'src/components.d.ts',
      dirs: ["src/components/"],
      // allow auto load markdown components under `./src/components/`
      extensions: ["vue", "md"],
      // allow auto import and register components used in markdown
      include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
      resolvers: [ElementPlusResolver({ importStyle: "sass" }), IconsResolver()]
    }),
    Icons({
      compiler: "vue3",
      autoInstall: true
    })
  ],
  server: {
    host: true,
    port: 5230
  },
  build: {
    // rollupOptions: {
    //   output: {
    //     manualChunks: {
    //       axios: ['axios'],
    //     },
    //   },
    // },
  }
});
export {
  vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,[encoded data, 11856 characters]
