vite.config.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /// <reference types="vitest" />
  2. import vue from '@vitejs/plugin-vue'
  3. import Icons from 'unplugin-icons/vite'
  4. import copy from 'rollup-plugin-copy'
  5. import { defineConfig } from 'vite'
  6. import banner from 'vite-plugin-banner'
  7. import dts from 'vite-plugin-dts'
  8. /* import analyze from 'rollup-plugin-analyzer' */
  9. import { bold, gray, lightGreen, yellow } from 'kolorist'
  10. import { resolve } from 'pathe'
  11. import pkg from './package.json'
  12. // eslint-disable-next-line no-console
  13. console.log(`${lightGreen('▲')} ${gray('■')} ${yellow('●')} ${bold('Tres')} v${pkg.version}`)
  14. // https://vitejs.dev/config/
  15. export default defineConfig({
  16. server: {
  17. port: 5174,
  18. },
  19. plugins: [
  20. vue({
  21. isProduction: false,
  22. template: {
  23. compilerOptions: {
  24. isCustomElement: tag => tag.startsWith('Tres') && tag !== 'TresCanvas' && tag !== 'TresErrorBoundary',
  25. },
  26. },
  27. }),
  28. dts({
  29. insertTypesEntry: true,
  30. }),
  31. banner({
  32. content: `/**\n * name: ${pkg.name}\n * version: v${
  33. pkg.version
  34. }\n * (c) ${new Date().getFullYear()}\n * description: ${pkg.description}\n * author: ${pkg.author}\n */`,
  35. }),
  36. Icons({
  37. }),
  38. // Inspect(),
  39. ],
  40. test: {
  41. environment: 'jsdom',
  42. globals: true,
  43. threads: false,
  44. },
  45. build: {
  46. // vite.config.ts
  47. lib: {
  48. entry: resolve(__dirname, 'src/index.ts'),
  49. name: 'tres',
  50. fileName: 'tres',
  51. formats: ['es'],
  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. },
  73. },
  74. },
  75. optimizeDeps: {
  76. exclude: ['vue', 'three'],
  77. },
  78. })