vite.config.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import path from "path"
  2. import { defineConfig } from "vite"
  3. import Vue from "@vitejs/plugin-vue"
  4. import Pages from "vite-plugin-pages"
  5. import Layouts from "vite-plugin-vue-layouts"
  6. import Icons from "unplugin-icons/vite"
  7. import IconsResolver from "unplugin-icons/resolver"
  8. import Components from "unplugin-vue-components/vite"
  9. import AutoImport from "unplugin-auto-import/vite"
  10. import WindiCSS from "vite-plugin-windicss"
  11. import { VitePWA } from "vite-plugin-pwa"
  12. import VueI18n from "@intlify/vite-plugin-vue-i18n"
  13. import Inspect from "vite-plugin-inspect"
  14. import ViteFonts from "vite-plugin-fonts"
  15. export default defineConfig({
  16. resolve: {
  17. alias: {
  18. "~/": `${path.resolve(__dirname, "src")}/`,
  19. },
  20. },
  21. plugins: [
  22. Vue({
  23. include: [/\.vue$/, /\.md$/],
  24. }),
  25. // https://github.com/hannoeru/vite-plugin-pages
  26. Pages({
  27. extensions: ["vue", "md"],
  28. }),
  29. // https://github.com/JohnCampionJr/vite-plugin-vue-layouts
  30. Layouts(),
  31. // https://github.com/antfu/unplugin-auto-import
  32. AutoImport({
  33. imports: [
  34. "vue",
  35. "vue-router",
  36. "vue-i18n",
  37. "@vueuse/head",
  38. "@vueuse/core",
  39. ],
  40. dts: "src/auto-imports.d.ts",
  41. }),
  42. // https://github.com/antfu/unplugin-vue-components
  43. Components({
  44. // allow auto load markdown components under `./src/components/`
  45. extensions: ["vue", "md"],
  46. // allow auto import and register components used in markdown
  47. include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
  48. // custom resolvers
  49. resolvers: [
  50. // auto import icons
  51. // https://github.com/antfu/unplugin-icons
  52. IconsResolver({
  53. componentPrefix: "",
  54. // enabledCollections: ['carbon']
  55. }),
  56. ],
  57. dts: "src/components.d.ts",
  58. }),
  59. // https://github.com/antfu/unplugin-icons
  60. Icons({
  61. autoInstall: true,
  62. }),
  63. // https://github.com/antfu/vite-plugin-windicss
  64. WindiCSS({}),
  65. // https://github.com/antfu/vite-plugin-pwa
  66. VitePWA({
  67. registerType: "autoUpdate",
  68. includeAssets: ["favicon.ico", "robots.txt", "safari-pinned-tab.svg"],
  69. manifest: {
  70. name: "Vitesse",
  71. short_name: "Vitesse",
  72. theme_color: "#ffffff",
  73. icons: [
  74. {
  75. src: "/pwa-192x192.png",
  76. sizes: "192x192",
  77. type: "image/png",
  78. },
  79. {
  80. src: "/pwa-512x512.png",
  81. sizes: "512x512",
  82. type: "image/png",
  83. },
  84. {
  85. src: "/pwa-512x512.png",
  86. sizes: "512x512",
  87. type: "image/png",
  88. purpose: "any maskable",
  89. },
  90. ],
  91. },
  92. }),
  93. // https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
  94. VueI18n({
  95. runtimeOnly: true,
  96. compositionOnly: true,
  97. include: [path.resolve(__dirname, "locales/**")],
  98. }),
  99. // https://github.com/antfu/vite-plugin-inspect
  100. Inspect({
  101. // change this to enable inspect for debugging
  102. enabled: false,
  103. }),
  104. // https://github.com/stafyniaksacha/vite-plugin-fonts
  105. ViteFonts({
  106. google: {
  107. families: ["Inter", "Roboto Mono"],
  108. },
  109. }),
  110. ],
  111. server: {
  112. fs: {
  113. strict: true,
  114. },
  115. },
  116. // https://github.com/antfu/vite-ssg
  117. ssgOptions: {
  118. script: "async",
  119. formatting: "minify",
  120. },
  121. optimizeDeps: {
  122. include: ["vue", "vue-router", "@vueuse/core", "@vueuse/head"],
  123. exclude: ["vue-demi"],
  124. },
  125. })