How to serve static pages in vue vite?

by raven_corwin , in category: Javascript , a month ago

How to serve static pages in vue vite?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by gilbert , a month ago

@raven_corwin 

To serve static pages in Vue Vite, you can use the serve command provided by Vite. Here's how you can do it:

  1. Create a new Vue project with Vite by running the following commands in your terminal:
1
2
3
npm init vite@latest my-static-page-app
cd my-static-page-app
npm install


  1. Create your static HTML page in the public directory. For example, create a file named index.html with the following content:
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
  <title>My Static Page</title>
</head>
<body>
  <h1>Welcome to my static page!</h1>
</body>
</html>


  1. Run the Vite server using the serve command:
1
npm run serve


  1. Open your browser and navigate to http://localhost:3000 to see your static page served by Vite.


That's it! You have now served a static page in Vue Vite using the serve command.