vite.config.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { defineConfig, loadEnv, ConfigEnv, UserConfig } from "vite";
  2. import { createHtmlPlugin } from "vite-plugin-html";
  3. import vue from "@vitejs/plugin-vue";
  4. import { resolve } from "path";
  5. // import eslintPlugin from "vite-plugin-eslint";
  6. import AutoImport from 'unplugin-auto-import/vite'
  7. import Components from 'unplugin-vue-components/vite'
  8. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  9. // https://vitejs.dev/config/
  10. export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
  11. const env = loadEnv(mode, process.cwd());
  12. return {
  13. resolve: {
  14. alias: {
  15. '~':resolve(__dirname, "./"),
  16. '@': resolve(__dirname, "./src")
  17. },
  18. },
  19. server: {
  20. host: "0.0.0.0",
  21. },
  22. plugins: [
  23. vue(),
  24. createHtmlPlugin({
  25. inject: {
  26. data: {
  27. title: env.VITE_BZD_ERP_APP_TITLE,
  28. },
  29. },
  30. }),
  31. // eslintPlugin({
  32. // include: ["src/**/*.js", "src/**/*.vue", "src/*.js", "src/*.vue"],
  33. // }),
  34. AutoImport({
  35. resolvers: [ElementPlusResolver()],
  36. }),
  37. Components({
  38. resolvers: [ElementPlusResolver()],
  39. }),
  40. ],
  41. // * 打包去除 console.log && debugger
  42. esbuild: {
  43. pure: env.VITE_DROP_CONSOLE ? ["console.log", "debugger"] : [],
  44. },
  45. };
  46. });