vite.config.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import { resolve } from "node:path";
  2. import { defineConfig } from "vite";
  3. import Vue from "@vitejs/plugin-vue";
  4. import Components from "unplugin-vue-components/vite";
  5. import AutoImport from "unplugin-auto-import/vite";
  6. import Icons from "unplugin-icons/vite";
  7. import IconsResolver from "unplugin-icons/resolver";
  8. import Inspect from "vite-plugin-inspect";
  9. import { VitePWA } from "vite-plugin-pwa";
  10. import VueDevTools from "vite-plugin-vue-devtools";
  11. import viteJSX from "@vitejs/plugin-vue-jsx";
  12. // vite.config.ts
  13. import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
  14. import UnoCss from "unocss/vite";
  15. // https://vitejs.dev/config/
  16. export default defineConfig({
  17. server: {
  18. host: "0.0.0.0",
  19. port: 8888,
  20. open: true,
  21. proxy: {},
  22. },
  23. plugins: [
  24. viteJSX(),
  25. Vue(
  26. {
  27. script: {
  28. propsDestructure: true,
  29. defineModel: true,
  30. },
  31. },
  32. ),
  33. Icons({
  34. scale: 1.5, // Scale of icons against 1em
  35. defaultStyle: "", // Style apply to icons
  36. defaultClass: "inline-block h-5 w-5 stroke-current md:h-6 md:w-6", // Class names apply to icons
  37. compiler: "vue3", // "vue2", "vue3", "jsx"
  38. jsx: "react", // "react" or "preact"
  39. autoInstall: true,
  40. }),
  41. // https://github.com/antfu/unplugin-auto-import
  42. AutoImport({
  43. imports: [
  44. "vue",
  45. "vue-router",
  46. "vue-i18n",
  47. "vue/macros",
  48. "@vueuse/head",
  49. "@vueuse/core",
  50. ],
  51. dts: "types/auto-imports.d.ts",
  52. dirs: [
  53. "src/composables",
  54. "src/store",
  55. ],
  56. vueTemplate: true,
  57. }),
  58. // https://github.com/antfu/unplugin-vue-components
  59. Components({
  60. extensions: ["vue"],
  61. include: [/\.vue$/, /\.vue\?vue/],
  62. dts: "types/components.d.ts",
  63. exclude: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/],
  64. resolvers: [
  65. IconsResolver(),
  66. ],
  67. }),
  68. // https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n
  69. VueI18nPlugin({
  70. runtimeOnly: true,
  71. compositionOnly: true,
  72. fullInstall: true,
  73. include: [resolve(__dirname, "src/locales/**")],
  74. }),
  75. // https://github.com/antfu/vite-plugin-pwa
  76. VitePWA({
  77. registerType: "autoUpdate",
  78. includeAssets: ["favicon.ico"],
  79. manifest: {
  80. name: "BootVue",
  81. short_name: "BootVue",
  82. theme_color: "#ffffff",
  83. icons: [
  84. {
  85. src: "/pwa-192x192.png",
  86. sizes: "192x192",
  87. type: "image/png",
  88. },
  89. {
  90. src: "/pwa-512x512.png",
  91. sizes: "512x512",
  92. type: "image/png",
  93. },
  94. {
  95. src: "/pwa-512x512.png",
  96. sizes: "512x512",
  97. type: "image/png",
  98. purpose: "any maskable",
  99. },
  100. ],
  101. },
  102. }),
  103. // https://github.com/antfu/vite-plugin-inspect
  104. // Visit http://localhost:3333/__inspect/ to see the inspector
  105. Inspect(),
  106. // https://github.com/webfansplz/vite-plugin-vue-devtools
  107. VueDevTools(),
  108. // https://github.com/unocss/unocss
  109. // see unocss.config.ts for config
  110. UnoCss(),
  111. ],
  112. resolve: {
  113. alias: {
  114. "~/": `${resolve(__dirname, "src")}/`,
  115. },
  116. },
  117. css: {
  118. preprocessorOptions: {
  119. scss: {
  120. additionalData: `
  121. @import "~/styles/variables.scss";
  122. `,
  123. javascriptEnabled: true,
  124. },
  125. },
  126. },
  127. // https://github.com/vitest-dev/vitest
  128. test: {
  129. environment: "jsdom",
  130. },
  131. });