vite.config.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import vueJsx from '@vitejs/plugin-vue-jsx'
  5. import Components from 'unplugin-vue-components/vite'
  6. import { VantResolver } from '@vant/auto-import-resolver'
  7. import { resolve } from 'path'
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. base: './',
  11. plugins: [
  12. vue(),
  13. vueJsx(),
  14. Components({
  15. resolvers: [VantResolver()]
  16. })
  17. ],
  18. resolve: {
  19. alias: {
  20. '@': fileURLToPath(new URL('./src', import.meta.url))
  21. }
  22. },
  23. build: {
  24. rollupOptions: {
  25. input: {
  26. monument: resolve(__dirname, 'monument/index.html'),
  27. bookFair: resolve(__dirname, 'book-fair/index.html'),
  28. tongyan: resolve(__dirname, 'tongyan/index.html'),
  29. birds: resolve(__dirname, 'birds/index.html'),
  30. wedding: resolve(__dirname, 'wedding/index.html')
  31. },
  32. output: {
  33. assetFileNames: (assetInfo) => {
  34. const name = assetInfo.name ?? ''
  35. const info = name.split('.')
  36. let extType = info[info.length - 1]
  37. if (/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/i.test(name)) {
  38. extType = 'media'
  39. } else if (/\.(png|jpe?g|gif|svg)(\?.*)?$/.test(name)) {
  40. extType = 'imgs'
  41. } else if (/\.(woff2?|eot|ttf|otf)(\?.*)?$/i.test(name)) {
  42. extType = 'fonts'
  43. }
  44. return `static/${extType}/[name]-[hash][extname]`
  45. },
  46. chunkFileNames: 'static/js/[name]-[hash].js',
  47. entryFileNames: 'static/js/[name]-[hash].js'
  48. }
  49. }
  50. }
  51. })