vite.config.ts 2.9 KB

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