vite.config.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { loadEnv } from 'vite';
  2. import uni from '@dcloudio/vite-plugin-uni';
  3. import path from 'path';
  4. // import viteCompression from 'vite-plugin-compression';
  5. import uniReadPagesV3Plugin from './common/router/utils/uni-read-pages-v3';
  6. import mpliveMainfestPlugin from './common/libs/mplive-manifest-plugin';
  7. // https://vitejs.dev/config/
  8. export default (command, mode) => {
  9. const env = loadEnv(mode, __dirname, 'SOUND_CHAIN_');
  10. return {
  11. envPrefix: "SOUND_CHAIN_",
  12. plugins: [
  13. uni(),
  14. // viteCompression({
  15. // verbose: false
  16. // }),
  17. uniReadPagesV3Plugin({
  18. pagesJsonDir: path.resolve(__dirname, './pages.json'),
  19. includes: ['path', 'aliasPath', 'name', 'meta'],
  20. }),
  21. mpliveMainfestPlugin(env.SOUND_CHAIN_MPLIVE_ON)
  22. ],
  23. server: {
  24. host: true,
  25. // open: true,
  26. port: env.SOUND_CHAIN_DEV_PORT,
  27. proxy: {
  28. "/api": {
  29. target: 'http://192.168.1.251:18993',
  30. changeOrigin: true,
  31. rewrite: (path) => path.replace(/^\/api/, ''),
  32. },
  33. },
  34. hmr: {
  35. overlay: true,
  36. }
  37. },
  38. };
  39. };