vite.config.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. import { defineConfig } from 'vite'
  5. import Unocss from 'unocss/vite'
  6. import { svelte } from '@sveltejs/vite-plugin-svelte'
  7. import { internalIpV4 } from 'internal-ip'
  8. // https://vitejs.dev/config/
  9. export default defineConfig(async ({ command, mode }) => {
  10. const host =
  11. process.env.TAURI_ENV_PLATFORM === 'android' ||
  12. process.env.TAURI_ENV_PLATFORM === 'ios'
  13. ? await internalIpV4()
  14. : 'localhost'
  15. return {
  16. plugins: [Unocss(), svelte()],
  17. build: {
  18. rollupOptions: {
  19. output: {
  20. entryFileNames: `assets/[name].js`,
  21. chunkFileNames: `assets/[name].js`,
  22. assetFileNames: `assets/[name].[ext]`
  23. }
  24. }
  25. },
  26. server: {
  27. host: '0.0.0.0',
  28. port: 5173,
  29. strictPort: true,
  30. hmr: {
  31. protocol: 'ws',
  32. host,
  33. port: 5183
  34. },
  35. fs: {
  36. allow: ['.', '../../tooling/api/dist']
  37. }
  38. }
  39. }
  40. })