vite.config.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /// <reference types="vitest" />
  2. import { defineConfig, Plugin } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import tsconfigPaths from 'vite-tsconfig-paths'
  5. import vueJsx from '@vitejs/plugin-vue-jsx'
  6. // import IstanbulPlugin from 'vite-plugin-istanbul'
  7. const plugins: Array<Plugin> = [vue(), tsconfigPaths(), vueJsx()]
  8. if (process.env.CYPRESS_TEST === 'true') {
  9. // console.info('instrumenting code coverage for e2e tests...')
  10. // plugins.push(
  11. // IstanbulPlugin({
  12. // cypress: true,
  13. // checkProd: true,
  14. // exclude: ['dist', '.nyc_output', 'node_modules', 'coverage', 'test'],
  15. // include: ['src/*']
  16. // })
  17. // )
  18. }
  19. // https://vitejs.dev/config/
  20. //@ts-ignore
  21. export default defineConfig(({ mode }) => ({
  22. plugins,
  23. test: {
  24. server: {
  25. deps: {
  26. inline: ['date-fns']
  27. }
  28. },
  29. environment: 'happy-dom',
  30. globals: true,
  31. coverage: {
  32. all: true,
  33. exclude: ['*.config.{ts,js}', '**/*.d.ts', 'src/main.ts', 'dist', 'test'],
  34. functions: 80,
  35. branches: 80,
  36. statements: 80
  37. }
  38. },
  39. build: {
  40. sourcemap: mode === 'production' ? false : 'inline'
  41. },
  42. server: {
  43. port: 3000,
  44. proxy: {
  45. // '/service': {
  46. // target: 'https://vr-test.scdjw.com.cn',
  47. // changeOrigin: true
  48. // },
  49. // '/scene_view_data': {
  50. // target: 'https://djqk-vr.obsv3.scrb-cd-1.sichuandaily.com.cn',
  51. // changeOrigin: true
  52. // },
  53. '/service': {
  54. target: 'https://vr-test.scdjw.com.cn',
  55. changeOrigin: true
  56. },
  57. '/page': {
  58. target: 'https://vr-test.scdjw.com.cn',
  59. changeOrigin: true,
  60. rewrite: (path) => path.replace(/^\/page/, '')
  61. }
  62. }
  63. }
  64. }))