vite.config.ts 1.7 KB

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