wimdeblauwe / vite-spring-boot

Apache License 2.0
8 stars 0 forks source link

Add `vite:reactrefresh` tag to support using React components in Thymeleaf #2

Closed wimdeblauwe closed 1 week ago

wimdeblauwe commented 1 week ago

When using React components, you need something extra to make it work in DEV mode. Laravel also has a directive called @vitereactrefresh for this purpose. According to https://docs.adonisjs.com/guides/references/edge#vitereactrefresh, this is the code is generates:

  <script type="module">
    import RefreshRuntime from 'http://localhost:5173/@react-refresh'
    RefreshRuntime.injectIntoGlobalHook(window)
    window.$RefreshReg$ = () => {}
    window.$RefreshSig$ = () => (type) => type
    window.__vite_plugin_react_preamble_installed__ = true
  </script>