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