How to import build files (.js, .css) into HTML?

I’m trying to deploy my first apps to my moralis server, but I get the error - html file missing

I have created a new html file for the app but having difficulties with importing js and css files so that my app shows on the webpage. Can anyone help me with this?

You import a css file like this

<link rel="stylesheet" href="path/to/css/file">

and a script like this

<script src="path/to/js/file"></script>
1 Like

Thanks for the reply! I’ve tried to import the js files like this but I’m sure I’m doing something wrong.

I create html file in src folder then I run cd Decentralized-Spotify/src
run yarn

Add all js files to html file like this:

<head>

    <!--Head Content-->

    <title>AUNS Streaming</title>

    <!-- Required meta tags -->

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>

    <body>

       

    <!-- Scripts -->

        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>

        <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>

        <script src="https://unpkg.com/moralis/dist/moralis.js"></script>

        <script src="src/setupTests.js"></script>

        <script src="src/reportwebVitals.js"></script>

        <script src="src/index.js"></script>

        <script src="src/App.js"></script>

        <script src="src/Home.js"></script>

        <script src="src/Album.js"></script>

        <script src="src/hooks/useIPFS.js"></script>

        <script src="src/hooks/useAudio.js"></script>

        <script src="src/hooks/useAlbum.js"></script>

        <script src="src/helpers/albumLists.js"></script>

        <script src="src/components/AudioPlayer.js"></script>

    </body>

</html>

Am i making the mistake with cd-in only the src folder? I was getting an issue with the compressed file size being too big when I tried the whole folder.

Or am I simply messing up the html file?

What exactly are you trying to do? Deploy the spotify clone on a moralis server of yours?

1 Like

yep that’s it! it works on the local host.

Also when I type some text in HTML file and deploy it to my server, it shows up. But can’t seem to get the spotify clone ui and data imported.

Because the spotify clone is in react, it is not vanilla html, js and css

1 Like

Ah I see, so what to do about the error that I’m missing html file?

Or is it missing it because I changed the cd to Decentralized-Spotify/src from just cd Decentralized-Spotify?

Not sure how you would go about deploying a react project, sorry

edit: check this, looks like it should help https://www.pluralsight.com/guides/deploy-a-react-app-on-a-server
Apparently you just run npm run build and you should get an index.html file which you then host

1 Like

Bro, that was it!!! I can’t tell you how much you helped with this! When we make some profits from our ecosystem I’ll be sure to hit you up! :slight_smile:

1 Like

Nice, glad you made it work :+1:

1 Like