简体   繁体   中英

Cannot remove the svelte default "Hello World" from the page

EDIT: It turns out it was only an issue on my computer, but an explanation would still be helpful if you have one. Thanks again!

I am attempting to create a development page for a website I am working on, and have a blank index.html page that redirects you to the development page. This all works as intended. I am using svelte to make things easier in future, however, when I deploy it, the svelte "Hello World" that shows up upon creating a new svelte project keeps appearing on top of the development page HTML. The odd thing about this is that it only happens when I deploy it, not when I load up the static HTML, not when I load up a local server. It doesn't even show up if I don't use a custom domain name. I am using cloudflare pages and cloudflare to redirect the domain name to the cloudflare page. My domain is registered with GoDaddy, if that at all matters.

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width,initial-scale=1'>

    <title>Book Planet UK</title>

    <link rel='icon' type='image/png' href='/favicon.png'>
    <link rel='stylesheet' href='/public/global.css'>
    <link rel='stylesheet' href='/build/bundle.css'>

    <script defer src='/build/bundle.js'></script>
</head>

<body>
    <script src="app.js"></script>
</body>
</html>

app.js

window.onload = function() {
    window.location.replace("under-construction/under-construction.html");
}

under-construction/under-construction.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width,initial-scale=1'>

    <title>Book Planet UK</title>

    <link rel='icon' type='image/png' href='/favicon.png'>
    <link rel='stylesheet' href='under-construction.css'>
    <link rel='stylesheet' href='/build/bundle.css'>

    <script defer src='/build/bundle.js'></script>
</head>

<body>
    <script src="under-construction.js"></script>
    <div class="overlay">
        <h1 class="title">Book Planet UK is currently undergoing development.</h1>
        <span class="title">We are hoping to be back by 2023, so hold tight until then! 🚀️</span>
        <br>
        <button onclick="location.href = '/public/staff/index.html';">Staff Login</button>
    </div>
</body>
</html>

under-construction/under-construction.css

@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');

* {
  background-image: url("https://webgradients.com/public/webgradients_png/008%20Rainy%20Ashville.png");
}

.title {
    background: transparent;
    font-family: 'Roboto', sans-serif;
    padding-top: 20px;
    padding-left: 5%;
    padding-right: 5%;
}

.overlay {
    background: rgba(240, 248, 255, 0.375);
    border-radius: 10px;
    padding-left: 5%;
    padding-right: 5%;
    width: auto;
    max-width: max-content;
    height: auto;
}

button {
    background: transparent;
    font-family: 'Roboto', sans-serif;
    width: 20%;
    height: 35px;
    color: #242024;
    border: 2px solid #242024;
    border-width: 2px;
    margin-left: 5%;
    align-items: center;
    border-radius: 3px;
    margin-top: 25px;
    margin-bottom: 25px;
    transition: 0.25s ease;
}

button:hover {
    transform: scale(1.05);
    cursor: pointer;
}

src/app.svelte

<script lang="ts">
</script>

<main>
</main>

<style>
</style>

The non-custom-domain website is deployed at https://book-planet-uk.pages.dev/ . The domain is https://bookplanetuk.co.uk/ . I get the feeling that this may be a "its on my machine" kinda thing, so let me know if it doesn't appear for you on the domain. I have restarted my computer just to check.

Thank you in advance for any and all help!

Your code is linked via the path /build/bundle.js , this looks like the path will remain the same, even if the code changes. That can easily lead to caching issues, where browsers will not get a newer version of the code.

To prevent this, build systems often add a hash to the file name or to a query string, so the URL will be different and the browser will get the new file. Would recommend doing something along those lines.

(This also applies to other resources like CSS.)

Remove the reference to bundle.js.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM