vite.config.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. // import styleImport from 'vite-plugin-style-import'
  4. import vueJsx from '@vitejs/plugin-vue-jsx'
  5. import legacy from '@vitejs/plugin-legacy'
  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. // eslint-disable-next-line @typescript-eslint/no-var-requires
  10. const path = require('path')
  11. function resolve(dir: string) {
  12. return path.join(__dirname, dir)
  13. }
  14. // https://vitejs.dev/config/
  15. // https://github.com/vitejs/vite/issues/1930 .env
  16. // const proxyUrl = 'https://www.colexiu.com/';
  17. const proxyUrl = 'https://test.colexiu.com/'
  18. export default defineConfig({
  19. base: './',
  20. plugins: [
  21. vue(),
  22. vueJsx(),
  23. legacy({
  24. targets: ['> 0.25%, not dead'],
  25. ignoreBrowserslistConfig: true
  26. }),
  27. AutoImport({
  28. resolvers: [ElementPlusResolver()]
  29. }),
  30. Components({
  31. resolvers: [ElementPlusResolver()]
  32. })
  33. ],
  34. css: {
  35. preprocessorOptions: {
  36. scss: {
  37. charset: false
  38. }
  39. },
  40. postcss: {
  41. plugins: [
  42. {
  43. postcssPlugin: 'internal:charset-removal',
  44. AtRule: {
  45. charset: atRule => {
  46. if (atRule.name === 'charset') {
  47. atRule.remove()
  48. }
  49. }
  50. }
  51. },
  52. require('tailwindcss'),
  53. require('autoprefixer')
  54. ]
  55. }
  56. },
  57. resolve: {
  58. alias: {
  59. '@': resolve('./src'),
  60. '@common': resolve('./src/common'),
  61. '@components': resolve('./src/components'),
  62. '@store': resolve('./src/store'),
  63. '@views': resolve('./src/views')
  64. }
  65. },
  66. server: {
  67. host: '0.0.0.0',
  68. port: 5100,
  69. strictPort: true,
  70. proxy: {
  71. '/api-auth': {
  72. target: proxyUrl,
  73. changeOrigin: true
  74. },
  75. '/api-teacher': {
  76. target: proxyUrl,
  77. changeOrigin: true
  78. },
  79. '/api-website': {
  80. target: proxyUrl,
  81. changeOrigin: true
  82. }
  83. }
  84. },
  85. build: {
  86. rollupOptions: {
  87. input: {
  88. index: resolve('index.html')
  89. }
  90. }
  91. }
  92. })