vite.config.ts 2.6 KB

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