vite.config.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { defineConfig } from 'vite';
  2. import vue from '@vitejs/plugin-vue';
  3. import { FileSystemIconLoader } from 'unplugin-icons/loaders';
  4. import Icons from 'unplugin-icons/vite';
  5. import Unfonts from 'unplugin-fonts/vite';
  6. import IconResolver from 'unplugin-icons/resolver';
  7. import Components from 'unplugin-vue-components/vite';
  8. import Pages from 'vite-plugin-pages';
  9. import Layouts from 'vite-plugin-vue-layouts';
  10. import path from 'path';
  11. import ImportMetaEnv from '@import-meta-env/unplugin';
  12. import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
  13. // https://vitejs.dev/config/
  14. export default defineConfig({
  15. envPrefix: process.env.HOPP_ALLOW_RUNTIME_ENV ? 'VITE_BUILDTIME_' : 'VITE_',
  16. envDir: path.resolve(__dirname, '../..'),
  17. server: {
  18. port: 3100,
  19. },
  20. resolve: {
  21. alias: {
  22. '~': path.resolve(__dirname, '../hoppscotch-sh-admin/src'),
  23. '@modules': path.resolve(__dirname, '../hoppscotch-sh-admin/src/modules'),
  24. },
  25. },
  26. plugins: [
  27. vue(),
  28. Pages({
  29. dirs: './src/pages',
  30. routeStyle: 'nuxt',
  31. }),
  32. Layouts({
  33. defaultLayout: 'default',
  34. layoutsDirs: 'src/layouts',
  35. }),
  36. VueI18nPlugin({
  37. runtimeOnly: false,
  38. compositionOnly: true,
  39. include: [path.resolve(__dirname, './locales/**')],
  40. }),
  41. Components({
  42. dts: './src/components.d.ts',
  43. dirs: ['./src/components', '../hoppscotch-ui/src/components'],
  44. directoryAsNamespace: true,
  45. resolvers: [
  46. IconResolver({
  47. prefix: 'icon',
  48. customCollections: ['auth'],
  49. }),
  50. (compName: string) => {
  51. if (compName.startsWith('Hopp'))
  52. return { name: compName, from: '@hoppscotch/ui' };
  53. else return undefined;
  54. },
  55. ],
  56. types: [
  57. {
  58. from: 'vue-tippy',
  59. names: ['Tippy'],
  60. },
  61. ],
  62. }),
  63. Icons({
  64. compiler: 'vue3',
  65. customCollections: {
  66. auth: FileSystemIconLoader('../hoppscotch-sh-admin/assets/icons/auth'),
  67. },
  68. }),
  69. Unfonts({
  70. fontsource: {
  71. families: [
  72. {
  73. name: 'Inter Variable',
  74. variables: ['variable-full'],
  75. },
  76. {
  77. name: 'Material Symbols Rounded Variable',
  78. variables: ['variable-full'],
  79. },
  80. {
  81. name: 'Roboto Mono Variable',
  82. variables: ['variable-full'],
  83. },
  84. ],
  85. },
  86. }),
  87. process.env.HOPP_ALLOW_RUNTIME_ENV
  88. ? ImportMetaEnv.vite({
  89. example: '../../.env.example',
  90. env: '../../.env',
  91. })
  92. : [],
  93. ],
  94. });