import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

export default defineConfig(({ mode }) => {
  if (mode === 'lib') {
    // Library build for npm
    return {
      plugins: [vue()],
      build: {
        lib: {
          entry: resolve(__dirname, 'src/index.ts'),
          name: 'FluxKitUI',
          fileName: 'fluxkit-ui'
        },
        rollupOptions: {
          external: ['vue'],
          output: {
            globals: { vue: 'Vue' }
          }
        }
      }
    }
  }
  
  // Demo build (default)
  return {
    plugins: [vue()],
    build: {
      outDir: 'dist'
    }
  }
})
