vite.config.ts 1.6 KB

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