windsonR / vite-plugin-virtual-html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dependencies aren't resolved properly

christian-bromann opened this issue · comments

Given the following template:

<html>
  <head>
    <base href="http://127.0.0.1:64406">
    <style>
      html, body {
        padding: 0;
        margin: 0;
      }
    </style>
    <script type="module">
      import { createElement, useState } from 'react'
      console.log(createElement)
    </script>
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>

With this plugin if I open the html on the server I get the following output:

<html>
  <head>
    <script type="module">
import RefreshRuntime from "/@react-refresh"
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
</script>

    <script type="module" src="/@vite/client"></script>

    <base href="http://127.0.0.1:64406">
    <style>
      html, body {
        padding: 0;
        margin: 0;
      }
    </style>
    <script type="module" src="/@id/__x00__/react.html?html-proxy&index=0.js"></script>
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>

Which fails loading the module:

GET http://127.0.0.1:64406/@id/__x00__/react.html?html-proxy&index=0.js net::ERR_CONNECTION_REFUSED

Anything I am missing?

Uff, removing <base href="http://127.0.0.1:64406"> fixed it. It was an artifact from some debugging before.