Skip to content

Instantly share code, notes, and snippets.

@basperheim
Created March 23, 2024 11:22
Show Gist options
  • Save basperheim/b7cf9d8ecefb79107631c6be9ed22928 to your computer and use it in GitHub Desktop.
Save basperheim/b7cf9d8ecefb79107631c6be9ed22928 to your computer and use it in GitHub Desktop.

Use a custom HTML file in Wails.io

Generate Wails.io project

Create a new Vanilla TS wails.io project with wails init -n myproject -t vanilla-ts.

Add a main.html file in assets

Create a new frontend/src/assets/main.html file:

<h1>hello world</h1>

Finally, modify the frontend/index.html as follows:

<!DOCTYPE html>
<html lang="en">
  <head>
    <script>
      document.addEventListener("DOMContentLoaded", function () {
        fetch("./src/assets/main.html")
          .then((response) => response.text())
          .then((html) => {
            document.getElementById("includedContent").innerHTML = html;
          })
          .catch((error) => console.error("Error loading content:", error));
      });
    </script>
  </head>
  <body>
    <!-- <div id="app"></div> -->
    <div id="includedContent"></div>
    <script src="./src/main.ts" type="module"></script>
  </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment