vite.config.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { defineConfig } from 'vite';
  2. import vue from '@vitejs/plugin-vue';
  3. import vueJsx from '@vitejs/plugin-vue-jsx';
  4. import Components from 'unplugin-vue-components/vite';
  5. import { VantResolver } from 'unplugin-vue-components/resolvers';
  6. import viteESLint from 'vite-plugin-eslint';
  7. import legacy from '@vitejs/plugin-legacy';
  8. // eslint-disable-next-line @typescript-eslint/no-var-requires
  9. const path = require('path');
  10. function resolve(dir: string) {
  11. return path.join(__dirname, dir);
  12. }
  13. // https://vitejs.dev/config/
  14. // https://github.com/vitejs/vite/issues/1930 .env
  15. // const proxyUrl = 'https://test.lexiaoya.cn/';
  16. // const proxyUrl = 'https://kt.colexiu.com/';
  17. // const proxyUrl = 'http://192.168.3.143:7093/';
  18. const proxyUrl = 'https://test.kt.colexiu.com/';
  19. export default defineConfig({
  20. base: './',
  21. plugins: [
  22. legacy({
  23. targets: ['chrome 52'],
  24. additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
  25. renderLegacyChunks: true,
  26. polyfills: [
  27. 'es.symbol',
  28. 'es.promise',
  29. 'es.promise.finally',
  30. 'es/map',
  31. 'es/set',
  32. 'es.array.filter',
  33. 'es.array.for-each',
  34. 'es.array.flat-map',
  35. 'es.object.define-properties',
  36. 'es.object.define-property',
  37. 'es.object.get-own-property-descriptor',
  38. 'es.object.get-own-property-descriptors',
  39. 'es.object.keys',
  40. 'es.object.to-string',
  41. 'web.dom-collections.for-each',
  42. 'esnext.global-this',
  43. 'esnext.string.match-all'
  44. ]
  45. }),
  46. vue(),
  47. vueJsx(),
  48. viteESLint(),
  49. Components({
  50. resolvers: [VantResolver()]
  51. })
  52. ],
  53. build: {
  54. target: 'es2015'
  55. },
  56. resolve: {
  57. alias: {
  58. '@': resolve('./src'),
  59. '@common': resolve('./src/common'),
  60. '@components': resolve('./src/components'),
  61. '@store': resolve('./src/store'),
  62. '@views': resolve('./src/views')
  63. }
  64. },
  65. server: {
  66. host: '0.0.0.0',
  67. port: 9002,
  68. strictPort: true,
  69. cors: true,
  70. https: false,
  71. proxy: {
  72. '/edu-oauth': {
  73. target: proxyUrl,
  74. changeOrigin: true
  75. },
  76. '/edu-app': {
  77. target: proxyUrl,
  78. changeOrigin: true
  79. }
  80. }
  81. }
  82. });