vite.config.ts 2.4 KB

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