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

export default defineConfig({
  plugins: [vue()],
  build: {
    lib: {
      entry: resolve(__dirname, 'src/index.ts'),
      formats: ['es'],
      fileName: (format) => `ni.${format}.js`
    },
    rollupOptions: {
      external: ['vue'],
      output: {
        globals: {
          vue: 'Vue'
        },
        assetFileNames: (assetInfo) => {
          return assetInfo.name === 'style.css' ? 'ni.css' : assetInfo.name || ''
        }
      }
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        // api: "modern-compiler", // Element Plus 中的解决办法
        silenceDeprecations: ['legacy-js-api']
      },
    },
  },
  resolve: {
    alias: {
      'ni': resolve(__dirname, 'src/index.ts'),
      '~': resolve(__dirname, 'src/components'),
      '@': resolve(__dirname, 'src')
    }
  }
}) 