vite.config.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { defineConfig } from 'vite'
  2. import path from 'path'
  3. import tailwindcss from '@tailwindcss/vite'
  4. import react from '@vitejs/plugin-react'
  5. function figmaAssetResolver() {
  6. return {
  7. name: 'figma-asset-resolver',
  8. resolveId(id: string) {
  9. if (id.startsWith('figma:asset/')) {
  10. const filename = id.replace('figma:asset/', '')
  11. return path.resolve(__dirname, 'src/assets', filename)
  12. }
  13. },
  14. }
  15. }
  16. export default defineConfig({
  17. plugins: [
  18. figmaAssetResolver(),
  19. // The React and Tailwind plugins are both required for Make, even if
  20. // Tailwind is not being actively used – do not remove them
  21. react(),
  22. tailwindcss(),
  23. ],
  24. resolve: {
  25. alias: {
  26. // Alias @ to the src directory
  27. '@': path.resolve(__dirname, './src'),
  28. },
  29. },
  30. // File types to support raw imports. Never add .css, .tsx, or .ts files to this.
  31. assetsInclude: ['**/*.svg', '**/*.csv'],
  32. server: {
  33. // 监听所有网络接口,允许局域网/外部 IP 访问,而不仅限于 localhost
  34. host: '0.0.0.0',
  35. port: 9345,
  36. },
  37. })