/*
 * @Author: 半生瓜 1515706227@qq.com
 * @Date: 2023-10-18 10:46:30
 * @LastEditors: 半生瓜 1515706227@qq.com
 * @LastEditTime: 2024-03-11 19:07:53
 * @FilePath: \v3_yyz\vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
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: './',//相对路径
  build: {
    minify: 'terser',
    terserOptions: {
        compress: {
            //生产环境时移除console
            drop_console: true,
            drop_debugger: true,
        }
    }
  },
  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` }
        }]
      }
    )
  },
})
