vite.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. import mpliveMainfestPlugin from './sheep/libs/mplive-manifest-plugin';
  7. import fs from 'fs';
  8. // https://vitejs.dev/config/
  9. export default (command, mode) => {
  10. const env = loadEnv(mode, __dirname, 'SHOPRO_');
  11. return {
  12. envPrefix: 'SHOPRO_',
  13. plugins: [
  14. uni(),
  15. // viteCompression({
  16. // verbose: false
  17. // }),
  18. uniReadPagesV3Plugin({
  19. pagesJsonDir: path.resolve(__dirname, './pages.json'),
  20. includes: ['path', 'aliasPath', 'name', 'meta'],
  21. }),
  22. mpliveMainfestPlugin(env.SHOPRO_MPLIVE_ON),
  23. ],
  24. server: {
  25. host: true,
  26. // open: true,
  27. port: env.SHOPRO_DEV_PORT,
  28. hmr: {
  29. overlay: true,
  30. },
  31. https: {
  32. cert: fs.readFileSync(path.join(__dirname, 'keys/STAR.zjkdywd.com.crt')),
  33. key: fs.readFileSync(path.join(__dirname, 'keys/STAR.zjkdywd.com.key')),
  34. },
  35. },
  36. };
  37. };