vite.config.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /// <reference types="vitest" />
  2. import { defineConfig, Plugin,loadEnv } 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. const viteEnv = loadEnv(mode, process.cwd())
  23. const { VITE_KANKAN_PROXY } = viteEnv
  24. return {
  25. plugins,
  26. test: {
  27. server: {
  28. deps: {
  29. inline: ['date-fns']
  30. }
  31. },
  32. environment: 'happy-dom',
  33. globals: true,
  34. coverage: {
  35. all: true,
  36. exclude: [
  37. '*.config.{ts,js}',
  38. '**/*.d.ts',
  39. 'src/main.ts',
  40. 'dist',
  41. 'test'
  42. ],
  43. functions: 80,
  44. branches: 80,
  45. statements: 80
  46. }
  47. },
  48. base: mode == 'development'?'':'extend',
  49. build: {
  50. sourcemap: mode === 'production' ? false : 'inline'
  51. },
  52. server: {
  53. port: 3600,
  54. proxy: {
  55. '/service': {
  56. target: 'https://vr-test.scdjw.com.cn',
  57. changeOrigin: true
  58. },
  59. '/kankan': {
  60. target: VITE_KANKAN_PROXY,
  61. changeOrigin: true,
  62. rewrite: (path) => path.replace(/^\/kankan/, '')
  63. }
  64. }
  65. }
  66. }
  67. })