vite.config.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import type { UserConfig, ConfigEnv } from 'vite';
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import { resolve } from "path";
  5. import AutoImport from 'unplugin-auto-import/vite'
  6. import Components from 'unplugin-vue-components/vite'
  7. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  8. //https://github.com/element-plus/unplugin-element-plus/blob/HEAD/README.zh-CN.md
  9. import ElementPlus from 'unplugin-element-plus/vite'
  10. export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
  11. // const env = loadEnv(mode, process.cwd(), '')
  12. console.log(command, mode);
  13. return {
  14. plugins: [vue(),
  15. AutoImport({
  16. resolvers: [ElementPlusResolver()],
  17. }),
  18. Components({
  19. resolvers: [ElementPlusResolver()],
  20. }),
  21. ElementPlus({
  22. // useSource: true
  23. })
  24. ],
  25. publicDir: "public",
  26. base: "./",
  27. server: {
  28. host: '0.0.0.0',
  29. port: 8888,
  30. open: false,
  31. strictPort: false,
  32. // proxy: {}
  33. },
  34. resolve: {
  35. alias: {
  36. "@": resolve(__dirname, "./src"),
  37. "components": resolve(__dirname, "./src/components"),
  38. "api": resolve(__dirname, "./src/api"),
  39. },
  40. },
  41. css: {
  42. // css预处理器
  43. preprocessorOptions: {
  44. scss: {
  45. // charset: false,
  46. additionalData: `@use "./src/assets/css/variable.scss" as *;`,
  47. },
  48. },
  49. },
  50. build: {
  51. outDir: 'dist',
  52. },
  53. }
  54. })