import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import dts from "vite-plugin-dts";
import { resolve } from "path";
import VueSetupExtend from "vite-plugin-vue-setup-extend";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { TDesignResolver } from "unplugin-vue-components/resolvers";

export default defineConfig({
	base: "/",
	plugins: [
		vue(),
		dts({
			include: "./src"
		}),
		VueSetupExtend(),
		AutoImport({
			imports: [
				"vue",
				"vue-router",
				"pinia",
				{
					"axios": [
						["default", "axios"]
					]
				}
			],
			dts: "src/auto-imports.d.ts",
			eslintrc: {
				enabled: true,
				globalsPropValue: true
			},
			resolvers: [
				TDesignResolver({
					library: "vue-next"
				})
			]
		}),
		Components({
			dirs: [
				"src/components",
				"src/layout",
				"src/views/components"
			],
			resolvers: [
				TDesignResolver({
					library: "vue-next"
				})
			]
		})
	],
	css: {
		preprocessorOptions: {
			less: {
				math: "always",
				lessOptions: {
					modifyVars: {
						"@btn-border-radius": "0"
					},
					javascriptEnabled: true
				}
			}
		}
	},
	define: {
		"process.env": {}
	},
	resolve: {
		alias: {
			"@": resolve(__dirname, "src")
		},
		extensions: [".js", ".json", ".ts"]
	},
	server: {
		port: 80,
		host: "imyeyu.dev"
	},
	build: {
		sourcemap: false,
		minify: "terser",
		terserOptions: {
			compress: {
				// eslint-disable-next-line camelcase
				drop_console: true,
				// eslint-disable-next-line camelcase
				drop_debugger: true
			}
		}
	}
});
