vite.config.ts 2.2 KB

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