Vite : Install2025/09/12 |
|
Install the front-end build tool Vite. |
|
| [1] | |
| [2] | Create a test Vite application with a vue.js template. |
|
debian@dlp:~$ npm create vite@latest testproject2 -- --template vue Need to install the following packages: create-vite@7.1.1 Ok to proceed? (y) > npx > create-vite testproject2 --template vue Scaffolding project in /home/debian/testproject2... Done. Now run: cd testproject2 npm install npm run devdebian@dlp:~$ cd testproject2 debian@dlp:~/testproject2$ npm install added 34 packages, and audited 35 packages in 7s 6 packages are looking for funding run `npm fund` for details found 0 vulnerabilitiesdebian@dlp:~/testproject2$ npm run dev > testproject2@0.0.0 dev > vite VITE v7.1.5 ready in 271 ms → Local: http://localhost:5173/ → Network: use --host to expose → press h + enter to show help # if you like to access to the app from remote hosts, add [--host] option debian@dlp:~/testproject2$ vi package.json
{
"name": "testproject2",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
// add follows
"dev": "vite --host",
"build": "vite build",
"preview": "vite preview"
},
debian@dlp:~/testproject2$
vi vite.config.js
export default defineConfig({
// add follows
server: {
host: true,
},
plugins: [vue()],
})
debian@dlp:~/testproject2$ npm run dev > testproject2@0.0.0 dev > vite --host VITE v7.1.5 ready in 242 ms → Local: http://localhost:5173/ → Network: http://10.0.0.30:5173/ → press h + enter to show help |
| Access to the URL that is shown on the console above, and then that's OK if following app is shown. |
|
| [3] | Modify the test application you created and check it works. |
|
debian@dlp:~$ cd testproject2
debian@dlp:~/testproject2$
vi src/components/HelloWorld.vue
<script setup>
import { ref } from 'vue'
defineProps({
msg: String,
// set [MyHello] string
MyHello: String
})
.....
.....
<template>
// insert tags
<h1 style="font-size: 36px; color: red;">{{ MyHello }}</h1>
<h1>{{ msg }}</h1>
debian@dlp:~/testproject2$
vi src/App.vue
<template>
<div>
<a href="https://vite.dev" target="_blank">
<img src="/vite.svg" class="logo" alt="Vite logo" />
</a>
<a href="https://vuejs.org/" target="_blank">
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
</a>
</div>
<HelloWorld MyHello="Hello Vite World!" msg="Vite + Vue" />
</template>
debian@dlp:~/testproject2$ npm run dev |
|
| Sponsored Link |
|
|