typora/note/前端/vue3/vue3-vite.md
2024-12-12 10:48:55 +08:00

36 lines
678 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 项目初始化
```bash
npm init vue@3.5.0
```
### 配置端口和监听地址
- vite.config.js
```js
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
server: {
port: 8998, // 自定义端口默认为5173
open: false, // 服务启动后,自动在浏览器中打开,默认是不打开的
hmr: true, // 为开发服务启用热更新,默认是不启用热更新的
host: '0.0.0.0',
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})
```