import {defineConfig} from 'vite'
import Vue from '@vitejs/plugin-vue'
import path from 'path'
import Pages from 'vite-plugin-pages'
import Layouts from 'vite-plugin-vue-layouts'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import {NaiveUiResolver} from 'unplugin-vue-components/resolvers'
import {viteCommonjs} from '@originjs/vite-plugin-commonjs'
import Unocss from 'unocss/vite'
import {presetAttributify, presetUno, presetIcons} from 'unocss'

const admin_path = 'admin'
export default defineConfig({
  base: `/${admin_path}/`,
  build: {
    outDir: `../public/${admin_path}`, assetsDir: 'lib'
  },
  resolve: {alias: {'~/': `${path.resolve(__dirname, 'src')}/`}},
  plugins: [Vue({reactivityTransform: true}), viteCommonjs(), Pages(), Layouts(), AutoImport({
    imports: ['vue', 'vue/macros', 'vue-router', '@vueuse/core',],
  }), Components({resolvers: [NaiveUiResolver()]}), Unocss({
    presets: [presetAttributify({}), presetUno(), presetIcons({
      warn: true,
    })],
  })]
})
