vite.config.ts 2.6 KB

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