vite.config.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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://dev.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. },
  41. resolve: {
  42. alias: {
  43. '@': resolve('./src'),
  44. '@common': resolve('./src/common'),
  45. '@components': resolve('./src/components'),
  46. '@store': resolve('./src/store'),
  47. '@views': resolve('./src/views')
  48. }
  49. },
  50. server: {
  51. host: '0.0.0.0',
  52. port: 5500,
  53. strictPort: true,
  54. proxy: {
  55. '/api-auth': {
  56. target: proxyUrl,
  57. changeOrigin: true
  58. },
  59. '/api-website': {
  60. target: proxyUrl,
  61. changeOrigin: true
  62. }
  63. }
  64. },
  65. build: {
  66. rollupOptions: {
  67. input: {
  68. index: resolve('index.html')
  69. }
  70. }
  71. }
  72. })