vite.config.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { defineConfig } from "vite"
  2. import vue from "@vitejs/plugin-vue"
  3. import Icons from 'unplugin-icons/vite'
  4. import IconResolver from 'unplugin-icons/resolver'
  5. import Components from 'unplugin-vue-components/vite'
  6. import path from 'path'
  7. // @ts-expect-error process is a nodejs global
  8. const host = process.env.TAURI_DEV_HOST
  9. export default defineConfig(async () => ({
  10. plugins: [
  11. vue(),
  12. Components({
  13. dts: './src/components.d.ts',
  14. resolvers: [
  15. IconResolver({
  16. prefix: 'icon',
  17. }),
  18. (compName: string) => {
  19. if (compName.startsWith('Hopp'))
  20. return { name: compName, from: '@hoppscotch/ui' }
  21. return undefined
  22. },
  23. ],
  24. types: [
  25. {
  26. from: 'vue-tippy',
  27. names: ['Tippy'],
  28. },
  29. ],
  30. include: [/\.vue$/, /\.vue\?vue/],
  31. dirs: ['src/components'],
  32. }),
  33. Icons({
  34. compiler: 'vue3',
  35. }),
  36. ],
  37. resolve: {
  38. alias: {
  39. "~": path.resolve(__dirname, "src"),
  40. "~/": path.resolve(__dirname, "src/"),
  41. },
  42. dedupe: ["vue"],
  43. },
  44. optimizeDeps: {
  45. include: ['@hoppscotch/kernel']
  46. },
  47. build: {
  48. rollupOptions: {
  49. output: {
  50. manualChunks: {
  51. kernel: ['@hoppscotch/kernel'],
  52. ui: ['@hoppscotch/ui'],
  53. }
  54. }
  55. }
  56. },
  57. // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
  58. clearScreen: false,
  59. server: {
  60. port: 1420,
  61. strictPort: true,
  62. host: host || false,
  63. hmr: host
  64. ? {
  65. protocol: "ws",
  66. host,
  67. port: 1421,
  68. }
  69. : undefined,
  70. watch: {
  71. ignored: ["**/src-tauri/**"],
  72. },
  73. },
  74. }))