vite.config.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 = process.env.TAURI_PLATFORM === 'android' || process.env.TAURI_PLATFORM === 'ios' ? (await internalIpV4()) : 'localhost'
  11. return {
  12. plugins: [Unocss(), svelte()],
  13. build: {
  14. rollupOptions: {
  15. output: {
  16. entryFileNames: `assets/[name].js`,
  17. chunkFileNames: `assets/[name].js`,
  18. assetFileNames: `assets/[name].[ext]`
  19. }
  20. }
  21. },
  22. server: {
  23. host: '0.0.0.0',
  24. port: 5173,
  25. strictPort: true,
  26. hmr: {
  27. protocol: 'ws',
  28. host,
  29. port: 5183
  30. },
  31. fs: {
  32. allow: ['.', '../../tooling/api/dist']
  33. }
  34. }
  35. }
  36. })