vite.config.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. threads: false,
  41. },
  42. build: {
  43. lib: {
  44. entry: resolve(__dirname, 'src/index.ts'),
  45. name: 'tres',
  46. fileName: 'tres',
  47. },
  48. watch: {
  49. include: [resolve(__dirname, 'src')],
  50. },
  51. copyPublicDir: false,
  52. rollupOptions: {
  53. plugins: [
  54. copy({
  55. targets: [{ src: 'src/types/tres-components.d.ts', dest: 'dist/types' }],
  56. }),
  57. /* analyze(), */
  58. /* visualizer({
  59. open: true,
  60. gzipSize: true,
  61. brotliSize: true,
  62. }), */
  63. ],
  64. external: ['vue', '@vueuse/core', 'three'],
  65. output: {
  66. exports: 'named',
  67. // Provide global variables to use in the UMD build
  68. // for externalized deps
  69. globals: {
  70. 'vue': 'Vue',
  71. '@vueuse/core': 'VueUseCore',
  72. 'three': 'Three',
  73. },
  74. },
  75. },
  76. },
  77. optimizeDeps: {
  78. exclude: ['vue', 'three'],
  79. },
  80. })