vite.config.ts 3.0 KB

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