vite.config.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import vue from "@vitejs/plugin-vue"
  2. import path from "path"
  3. import { FileSystemIconLoader } from "unplugin-icons/loaders"
  4. import IconResolver from "unplugin-icons/resolver"
  5. import Icons from "unplugin-icons/vite"
  6. import Components from "unplugin-vue-components/vite"
  7. import { defineConfig } from "vite"
  8. import WindiCSS from "vite-plugin-windicss"
  9. module.exports = defineConfig({
  10. plugins: [
  11. vue(),
  12. WindiCSS({
  13. root: path.resolve(__dirname),
  14. }),
  15. Components({
  16. dts: "./src/components.d.ts",
  17. dirs: ["./src/components"],
  18. directoryAsNamespace: true,
  19. resolvers: [
  20. IconResolver({
  21. prefix: "icon",
  22. customCollections: ["hopp", "auth", "brands"],
  23. }),
  24. ],
  25. }),
  26. Icons({
  27. compiler: "vue3",
  28. customCollections: {
  29. hopp: FileSystemIconLoader("../hoppscotch-common/assets/icons"),
  30. auth: FileSystemIconLoader("../hoppscotch-common/assets/icons/auth"),
  31. brands: FileSystemIconLoader(
  32. "../hoppscotch-common/assets/icons/brands"
  33. ),
  34. },
  35. }),
  36. ], // to process SFC
  37. build: {
  38. lib: {
  39. entry: path.resolve(__dirname, "src/index.ts"),
  40. name: "hopp-ui",
  41. formats: ["es"], // adding 'umd' requires globals set to every external module
  42. fileName: (format) => `hopp-ui.${format}.js`,
  43. },
  44. rollupOptions: {
  45. // external modules won't be bundled into HoppUI library
  46. external: ["vue"], // not every external has a global
  47. output: {
  48. // disable warning on src/index.ts using both default and named export
  49. exports: "named",
  50. // Provide global variables to use in the UMD build
  51. // for externalized deps (not useful if 'umd' is not in lib.formats)
  52. globals: {
  53. vue: "Vue",
  54. },
  55. },
  56. },
  57. emptyOutDir: false, // to retain the types folder generated by tsc
  58. },
  59. })