import vue from '@vitejs/plugin-vue';
import { fileURLToPath, URL } from 'node:url';
import { resolve } from "path";
import AutoImport from 'unplugin-auto-import/vite';
import { TDesignResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import { defineConfig } from 'vite';

import svgLoader from "vite-svg-loader";

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    svgLoader(),
    Components({
      resolvers: [TDesignResolver({library: 'vue-next'})],
    }),
    AutoImport({
      imports: ['vue', 'vue-router', 'pinia'],
      resolvers: [TDesignResolver({library: 'vue-next'}),],
    }),
  ],
  base: "/blog/",
  server:{
    host:'0.0.0.0',
    port: 8080,
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  css: {
    preprocessorOptions: {
      less: {
        // additionalData: '@import "colorofchina/color.less";',
        modifyVars: {
          hack: `true; @import (reference) "${resolve("src/assets/global.less")}";`,
        },
        javascriptEnabled: true,
      },
    },
  },
})
