vite.config.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 './sheep/router/utils/uni-read-pages-v3';
  6. // 引入直播组件
  7. import replaceManifest from './modifyManifest'
  8. // https://vitejs.dev/config/
  9. export default (command, mode) => {
  10. const env = loadEnv(mode, __dirname, 'SHOPRO_');
  11. if (env.SHOPRO_MPLIVE_ON === 'true') {
  12. replaceManifest(`{
  13. "live-player-plugin": {
  14. "version": "1.3.5",
  15. "provider": "wx2b03c6e691cd7370"
  16. }
  17. }`, 'push')
  18. } else {
  19. replaceManifest(`{
  20. "live-player-plugin": {
  21. "version": "1.3.5",
  22. "provider": "wx2b03c6e691cd7370"
  23. }
  24. }`, 'delete')
  25. }
  26. return {
  27. envPrefix: "SHOPRO_",
  28. plugins: [
  29. uni(),
  30. // viteCompression({
  31. // verbose: false
  32. // }),
  33. uniReadPagesV3Plugin({
  34. pagesJsonDir: path.resolve(__dirname, './pages.json'),
  35. includes: ['path', 'aliasPath', 'name', 'meta'],
  36. }),
  37. ],
  38. server: {
  39. host: true,
  40. // open: true,
  41. port: env.SHOPRO_DEV_PORT,
  42. hmr: {
  43. overlay: true,
  44. },
  45. },
  46. };
  47. };