vite.config.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /// <reference types="vitest" />
  2. import * as path from "path";
  3. import { defineConfig } from "vite";
  4. import vue from "@vitejs/plugin-vue";
  5. import vueI18n from "@intlify/vite-plugin-vue-i18n";
  6. import pkg from "./package.json";
  7. import pages from "vite-plugin-pages";
  8. import layouts from "vite-plugin-vue-layouts";
  9. import components from "unplugin-vue-components/vite";
  10. process.env.VITE_APP_VERSION = pkg.version;
  11. if (process.env.NODE_ENV === "production") {
  12. process.env.VITE_APP_BUILD_EPOCH = new Date().getTime().toString();
  13. }
  14. export default defineConfig({
  15. base: '/krgame/',
  16. plugins: [
  17. vue({
  18. script: {
  19. refSugar: true,
  20. },
  21. }),
  22. pages(),
  23. layouts(),
  24. // https://github.com/antfu/unplugin-vue-components
  25. components({
  26. // allow auto load markdown components under `./src/components/`
  27. extensions: ["vue", "md"],
  28. // allow auto import and register components used in markdown
  29. include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
  30. dts: "src/components.d.ts",
  31. }),
  32. // https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
  33. vueI18n({
  34. runtimeOnly: true,
  35. compositionOnly: true,
  36. include: [path.resolve(__dirname, "locales/**")],
  37. }),
  38. ],
  39. resolve: {
  40. alias: {
  41. "@": path.resolve(__dirname, "./src"),
  42. },
  43. },
  44. test: {
  45. include: ['tests/unit/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
  46. },
  47. });