vite.config.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /// <reference types="vitest" />
  2. import vue from '@vitejs/plugin-vue'
  3. import copy from 'rollup-plugin-copy'
  4. import { defineConfig } from 'vite'
  5. import banner from 'vite-plugin-banner'
  6. import dts from 'vite-plugin-dts'
  7. /* import analyze from 'rollup-plugin-analyzer' */
  8. import { bold, gray, lightGreen, yellow } from 'kolorist'
  9. import { resolve } from 'pathe'
  10. import pkg from './package.json'
  11. // eslint-disable-next-line no-console
  12. console.log(`${lightGreen('▲')} ${gray('■')} ${yellow('●')} ${bold('Tres')} v${pkg.version}`)
  13. // https://vitejs.dev/config/
  14. export default defineConfig({
  15. server: {
  16. port: 5174,
  17. },
  18. plugins: [
  19. vue({
  20. isProduction: false,
  21. template: {
  22. compilerOptions: {
  23. isCustomElement: tag => tag.startsWith('Tres') && tag !== 'TresCanvas',
  24. },
  25. },
  26. }),
  27. dts({
  28. insertTypesEntry: true,
  29. }),
  30. banner({
  31. content: `/**\n * name: ${pkg.name}\n * version: v${
  32. pkg.version
  33. }\n * (c) ${new Date().getFullYear()}\n * description: ${pkg.description}\n * author: ${pkg.author}\n */`,
  34. }),
  35. // Inspect(),
  36. ],
  37. test: {
  38. environment: 'jsdom',
  39. globals: true,
  40. },
  41. build: {
  42. // vite.config.ts
  43. lib: {
  44. entry: resolve(__dirname, 'src/index.ts'),
  45. name: 'tres',
  46. fileName: 'tres',
  47. formats: ['es'],
  48. },
  49. watch: {
  50. include: [resolve(__dirname, 'src')],
  51. },
  52. copyPublicDir: false,
  53. rollupOptions: {
  54. plugins: [
  55. copy({
  56. targets: [{ src: 'src/types/tres-components.d.ts', dest: 'dist/types' }],
  57. }),
  58. /* analyze(), */
  59. /* visualizer({
  60. open: true,
  61. gzipSize: true,
  62. brotliSize: true,
  63. }), */
  64. ],
  65. external: ['vue', '@vueuse/core', 'three'],
  66. output: {
  67. exports: 'named',
  68. },
  69. },
  70. },
  71. optimizeDeps: {
  72. exclude: ['vue', 'three'],
  73. },
  74. })