vite.config.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. // vite.config.ts
  44. lib: {
  45. entry: resolve(__dirname, 'src/index.ts'),
  46. name: 'tres',
  47. fileName: 'tres',
  48. formats: ['es'],
  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. },
  70. },
  71. },
  72. optimizeDeps: {
  73. exclude: ['vue', 'three'],
  74. },
  75. })