vite.config.js 951 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import qiankun from 'vite-plugin-qiankun'
  5. const SUB_APP_NAME = 'mobile-app'
  6. const useDevMode = true
  7. // 移动端子应用
  8. export default defineConfig(({ mode }) => {
  9. const isProd = mode === 'production'
  10. return {
  11. base: isProd ? '/mobile/' : '/',
  12. plugins: [
  13. vue(),
  14. qiankun(SUB_APP_NAME, { useDevMode: !isProd }),
  15. ],
  16. resolve: {
  17. alias: {
  18. '@': fileURLToPath(new URL('./src', import.meta.url)),
  19. },
  20. },
  21. server: {
  22. host: '0.0.0.0',
  23. port: 7200,
  24. strictPort: true,
  25. cors: true,
  26. origin: 'http://localhost:7200',
  27. headers: {
  28. 'Access-Control-Allow-Origin': '*',
  29. },
  30. },
  31. build: {
  32. target: 'es2015',
  33. rollupOptions: {
  34. output: {
  35. chunkFileNames: 'assets/[name]-[hash].js',
  36. },
  37. },
  38. },
  39. }
  40. })