vite.config.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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://dev.kt.colexiu.com/';
  17. // const proxyUrl = 'http://192.168.3.143:7989/';
  18. export default defineConfig({
  19. base: './',
  20. plugins: [
  21. legacy({
  22. targets: ['chrome 52'],
  23. additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
  24. renderLegacyChunks: true,
  25. polyfills: [
  26. 'es.symbol',
  27. 'es.promise',
  28. 'es.promise.finally',
  29. 'es/map',
  30. 'es/set',
  31. 'es.array.filter',
  32. 'es.array.for-each',
  33. 'es.array.flat-map',
  34. 'es.object.define-properties',
  35. 'es.object.define-property',
  36. 'es.object.get-own-property-descriptor',
  37. 'es.object.get-own-property-descriptors',
  38. 'es.object.keys',
  39. 'es.object.to-string',
  40. 'web.dom-collections.for-each',
  41. 'esnext.global-this',
  42. 'esnext.string.match-all'
  43. ]
  44. }),
  45. vue(),
  46. vueJsx(),
  47. viteESLint(),
  48. Components({
  49. resolvers: [VantResolver()]
  50. })
  51. ],
  52. build: {
  53. target: 'es2015'
  54. },
  55. resolve: {
  56. alias: {
  57. '@': resolve('./src'),
  58. '@common': resolve('./src/common'),
  59. '@components': resolve('./src/components'),
  60. '@store': resolve('./src/store'),
  61. '@views': resolve('./src/views')
  62. }
  63. },
  64. server: {
  65. host: '0.0.0.0',
  66. port: 9002,
  67. strictPort: true,
  68. cors: true,
  69. https: false,
  70. proxy: {
  71. '/edu-app': {
  72. target: proxyUrl,
  73. changeOrigin: true
  74. }
  75. }
  76. }
  77. });