vite.config.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 Inspect from 'vite-plugin-inspect'
  8. /* import analyze from 'rollup-plugin-analyzer' */
  9. import { bold, gray, lightGreen, yellow } from 'kolorist'
  10. import { resolve } from 'pathe'
  11. /* ß */
  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. plugins: [
  21. vue({
  22. isProduction: false,
  23. template: {
  24. compilerOptions: {
  25. isCustomElement: tag => tag.startsWith('Tres') && tag !== 'TresCanvas',
  26. },
  27. },
  28. }),
  29. dts({
  30. insertTypesEntry: true,
  31. }),
  32. banner({
  33. content: `/**\n * name: ${pkg.name}\n * version: v${
  34. pkg.version
  35. }\n * (c) ${new Date().getFullYear()}\n * description: ${pkg.description}\n * author: ${pkg.author}\n */`,
  36. }),
  37. Inspect(),
  38. ],
  39. test: {
  40. environment: 'jsdom',
  41. globals: true,
  42. threads: false,
  43. },
  44. build: {
  45. lib: {
  46. entry: resolve(__dirname, 'src/index.ts'),
  47. name: 'tres',
  48. fileName: 'tres',
  49. },
  50. watch: {
  51. include: [resolve(__dirname, 'src')],
  52. },
  53. copyPublicDir: false,
  54. rollupOptions: {
  55. plugins: [
  56. copy({
  57. targets: [{ src: 'src/types/tres-components.d.ts', dest: 'dist/types' }],
  58. }),
  59. /* analyze(), */
  60. /* visualizer({
  61. open: true,
  62. gzipSize: true,
  63. brotliSize: true,
  64. }), */
  65. ],
  66. external: ['vue', '@vueuse/core', 'three'],
  67. output: {
  68. exports: 'named',
  69. // Provide global variables to use in the UMD build
  70. // for externalized deps
  71. globals: {
  72. 'vue': 'Vue',
  73. '@vueuse/core': 'VueUseCore',
  74. 'three': 'Three',
  75. },
  76. },
  77. },
  78. },
  79. optimizeDeps: {
  80. exclude: ['vue', 'three'],
  81. },
  82. })