vite.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2019-2024 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 { internalIpV4Sync } from 'internal-ip'
  8. const host = process.env.TAURI_DEV_HOST
  9. // https://vitejs.dev/config/
  10. export default defineConfig({
  11. plugins: [Unocss(), svelte()],
  12. build: {
  13. rollupOptions: {
  14. output: {
  15. entryFileNames: `assets/[name].js`,
  16. chunkFileNames: `assets/[name].js`,
  17. assetFileNames: `assets/[name].[ext]`
  18. }
  19. }
  20. },
  21. // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
  22. // prevent vite from obscuring rust errors
  23. clearScreen: false,
  24. // tauri expects a fixed port, fail if that port is not available
  25. server: {
  26. host: host ? '0.0.0.0' : false,
  27. port: 1420,
  28. strictPort: true,
  29. hmr: host
  30. ? {
  31. protocol: 'ws',
  32. host: internalIpV4Sync(),
  33. port: 1430
  34. }
  35. : undefined,
  36. fs: {
  37. allow: ['.', '../../tooling/api/dist']
  38. }
  39. }
  40. })