vite.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { defineConfig, UserConfigExport } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import path from 'path'
  4. import WindiCss from 'vite-plugin-windicss';
  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://vitejs.dev/config/
  9. export default defineConfig(({ command }) => {
  10. const config: UserConfigExport = {
  11. // base:'/app/xdjx/',
  12. // base: '/app/xdjy/',
  13. base: '/app/xdhq/',
  14. resolve: {
  15. alias: {
  16. '~': `${path.resolve(__dirname, 'src')}`,
  17. '~/': `${path.resolve(__dirname, 'src/')}`,
  18. '~components': `${path.resolve(__dirname, 'src/components')}`,
  19. '@': `${path.resolve(__dirname, 'src')}`,
  20. },
  21. },
  22. css: {
  23. preprocessorOptions: {
  24. scss: {
  25. additionalData: `@use "~/styles/element/index.scss" as *;`,
  26. },
  27. },
  28. },
  29. plugins: [
  30. vue(),
  31. WindiCss(),
  32. AutoImport({
  33. resolvers: [ElementPlusResolver()],
  34. }),
  35. Components({
  36. resolvers: [ElementPlusResolver()],
  37. }),
  38. ],
  39. build: {
  40. // target: 'modules'
  41. target: 'esnext',
  42. rollupOptions: {
  43. output: {
  44. manualChunks: {
  45. lodash: ['lodash-es'],
  46. echarts: ['echarts'],
  47. axios: ['axios']
  48. }
  49. }
  50. }
  51. },
  52. }
  53. if (command === 'serve') {
  54. config.base = "/"
  55. } else {
  56. }
  57. return config
  58. }
  59. )