vite.config.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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-website': {
  76. target: proxyUrl,
  77. changeOrigin: true
  78. }
  79. }
  80. },
  81. build: {
  82. rollupOptions: {
  83. input: {
  84. index: resolve('index.html')
  85. }
  86. }
  87. }
  88. })