import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import postCssPxToRem from "postcss-pxtorem";

export default defineConfig({
  base: './',//相对路径
  plugins: [
    vue(),
    Components({
      resolvers: [ElementPlusResolver()]
    }),
    AutoImport({
      resolvers: [ElementPlusResolver()]
    }),
  ],
  css: {
    postcss:
    {
      plugins:
        [postCssPxToRem({
          rootValue: 192,
          // 1rem，根据 设计稿宽度/10 进行设置
          propList: ['*']
          // 需要转换的属性，这里选择全部都进行转换
        })]
    }
  },
  configureWebpack: (config) => {
    console.log("config");
    config.module.rules.push(
      {
        test: path.resolve(__dirname, 'node_modules/leader-line/'),
        use: [{
          loader: 'skeleton-loader',
          options: { procedure: content => `${content}export default LeaderLine` }
        }]
      }
    )
  },
})
