import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { fileURLToPath } from 'node:url'
import markdown from '@ldesign/vite-plugin-markdown'
import prism from 'markdown-it-prism'

const isCustomElement = tag => tag.includes('ldesign')

export default ({command}) => {
  return defineConfig({
    base: './',
    publicDir: 'src/assets',
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
      }
    },
    build: {},
    plugins: [
      vue({
        include: [/\.vue$/, /\.md$/],
        template: {
          compilerOptions: {
            isCustomElement,
          },
        },
      }),
      vueJsx({
        isCustomElement,
      }),
      markdown({
        headEnabled: true,
        markdownItUses: [
          prism
        ]
      }),
    ],
    optimizeDeps: {
      // disabled: 'dev'
    },
    server: {
      host: true,
      port: 3000,
    }
  })
}