vite.config.js 1.1 KB

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