vite.config.test.js 947 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import laravel from 'laravel-vite-plugin'
  2. import { defineConfig } from 'vite'
  3. import fs from 'fs';
  4. import { homedir } from 'os'
  5. import { resolve } from 'path'
  6. let host = 'orion4.test'
  7. export default defineConfig({
  8. plugins: [
  9. laravel({
  10. input: 'resources/js/app.js',
  11. refresh: true,
  12. }),
  13. ],
  14. server: detectServerConfig(host),
  15. })
  16. function detectServerConfig(host) {
  17. let keyPath = resolve(homedir(), `.config/valet/Certificates/${host}.key`)
  18. let certificatePath = resolve(homedir(), `.config/valet/Certificates/${host}.crt`)
  19. if (!fs.existsSync(keyPath)) {
  20. return {}
  21. }
  22. if (!fs.existsSync(certificatePath)) {
  23. return {}
  24. }
  25. return {
  26. hmr: {host},
  27. host,
  28. https: {
  29. key: fs.readFileSync(keyPath),
  30. cert: fs.readFileSync(certificatePath),
  31. },
  32. watch: {
  33. usePolling: true,
  34. }
  35. }
  36. }