vite.config.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { resolve } from 'node:path';
  2. import { URL, fileURLToPath } from 'node:url';
  3. import VueI18n from '@intlify/unplugin-vue-i18n/vite';
  4. import vue from '@vitejs/plugin-vue';
  5. import vueJsx from '@vitejs/plugin-vue-jsx';
  6. import Unocss from 'unocss/vite';
  7. import AutoImport from 'unplugin-auto-import/vite';
  8. import IconsResolver from 'unplugin-icons/resolver';
  9. import Icons from 'unplugin-icons/vite';
  10. import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';
  11. import Components from 'unplugin-vue-components/vite';
  12. import { defineConfig } from 'vite';
  13. import { VitePWA } from 'vite-plugin-pwa';
  14. import markdown from 'vite-plugin-vue-markdown';
  15. import svgLoader from 'vite-svg-loader';
  16. import { configDefaults } from 'vitest/config';
  17. const baseUrl = process.env.BASE_URL ?? '/';
  18. // https://vitejs.dev/config/
  19. export default defineConfig({
  20. plugins: [
  21. VueI18n({
  22. runtimeOnly: true,
  23. jitCompilation: true,
  24. compositionOnly: true,
  25. fullInstall: true,
  26. strictMessage: false,
  27. include: [
  28. resolve(__dirname, 'locales/**'),
  29. ],
  30. }),
  31. AutoImport({
  32. imports: [
  33. 'vue',
  34. 'vue-router',
  35. '@vueuse/core',
  36. 'vue-i18n',
  37. {
  38. 'naive-ui': ['useDialog', 'useMessage', 'useNotification', 'useLoadingBar'],
  39. },
  40. ],
  41. vueTemplate: true,
  42. eslintrc: {
  43. enabled: true,
  44. },
  45. }),
  46. Icons({ compiler: 'vue3' }),
  47. vue({
  48. include: [/\.vue$/, /\.md$/],
  49. }),
  50. vueJsx(),
  51. markdown(),
  52. svgLoader(),
  53. VitePWA({
  54. registerType: 'autoUpdate',
  55. strategies: 'generateSW',
  56. manifest: {
  57. name: 'IT Tools',
  58. description: 'Aggregated set of useful tools for developers.',
  59. display: 'standalone',
  60. lang: 'fr-FR',
  61. start_url: `${baseUrl}?utm_source=pwa&utm_medium=pwa`,
  62. orientation: 'any',
  63. theme_color: '#18a058',
  64. background_color: '#f1f5f9',
  65. icons: [
  66. {
  67. src: '/favicon-16x16.png',
  68. type: 'image/png',
  69. sizes: '16x16',
  70. },
  71. {
  72. src: '/favicon-32x32.png',
  73. type: 'image/png',
  74. sizes: '32x32',
  75. },
  76. {
  77. src: '/android-chrome-192x192.png',
  78. sizes: '192x192',
  79. type: 'image/png',
  80. },
  81. {
  82. src: '/android-chrome-512x512.png',
  83. sizes: '512x512',
  84. type: 'image/png',
  85. purpose: 'any maskable',
  86. },
  87. ],
  88. },
  89. }),
  90. Components({
  91. dirs: ['src/'],
  92. extensions: ['vue', 'md'],
  93. include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
  94. resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
  95. }),
  96. Unocss(),
  97. ],
  98. base: baseUrl,
  99. resolve: {
  100. alias: {
  101. '@': fileURLToPath(new URL('./src', import.meta.url)),
  102. },
  103. },
  104. define: {
  105. 'import.meta.env.PACKAGE_VERSION': JSON.stringify(process.env.npm_package_version),
  106. },
  107. test: {
  108. exclude: [...configDefaults.exclude, '**/*.e2e.spec.ts'],
  109. },
  110. build: {
  111. target: 'esnext',
  112. },
  113. });