|
1
|
# Vue.js Setup |
|
2
|
|
|
3
|
Configuration requirements for Vue.js applications in the Replit environment. |
|
4
|
|
|
5
|
## Vite-based Vue Projects (Recommended) |
|
6
|
|
|
7
|
Most modern Vue projects use Vite. Configure `vite.config.ts`: |
|
8
|
|
|
9
|
```typescript |
|
10
|
import { defineConfig } from 'vite'; |
|
11
|
import vue from '@vitejs/plugin-vue'; |
|
12
|
|
|
13
|
export default defineConfig({ |
|
14
|
plugins: [vue()], |
|
15
|
server: { |
|
16
|
host: '0.0.0.0', |
|
17
|
port: 5000, |
|
18
|
allowedHosts: true, |
|
19
|
}, |
|
20
|
}); |
|
21
|
``` |
|
22
|
|
|
23
|
## Vue CLI Projects |
|
24
|
|
|
25
|
For older Vue CLI projects, configure `vue.config.js`: |
|
26
|
|
|
27
|
```javascript |
|
28
|
module.exports = { |
|
29
|
devServer: { |
|
30
|
host: '0.0.0.0', |
|
31
|
port: 5000, |
|
32
|
allowedHosts: 'all', |
|
33
|
// Or use disableHostCheck for older versions: |
|
34
|
// disableHostCheck: true, |
|
35
|
}, |
|
36
|
}; |
|
37
|
``` |
|
38
|
|
|
39
|
## Nuxt.js Projects |
|
40
|
|
|
41
|
For Nuxt 3, configure `nuxt.config.ts`: |
|
42
|
|
|
43
|
```typescript |
|
44
|
export default defineNuxtConfig({ |
|
45
|
devServer: { |
|
46
|
host: '0.0.0.0', |
|
47
|
port: 5000, |
|
48
|
}, |
|
49
|
vite: { |
|
50
|
server: { |
|
51
|
allowedHosts: true, |
|
52
|
}, |
|
53
|
}, |
|
54
|
}); |
|
55
|
``` |
|
56
|
|
|
57
|
For Nuxt 2, configure `nuxt.config.js`: |
|
58
|
|
|
59
|
```javascript |
|
60
|
export default { |
|
61
|
server: { |
|
62
|
host: '0.0.0.0', |
|
63
|
port: 5000, |
|
64
|
}, |
|
65
|
}; |
|
66
|
``` |
|
67
|
|
|
68
|
## Connecting to Backend API |
|
69
|
|
|
70
|
Use environment variables for API URLs: |
|
71
|
|
|
72
|
```typescript |
|
73
|
// composables/useApi.ts |
|
74
|
export const useApi = () => { |
|
75
|
const baseUrl = import.meta.env.VITE_API_URL || ''; |
|
76
|
|
|
77
|
return { |
|
78
|
fetch: (endpoint: string) => fetch(`${baseUrl}${endpoint}`), |
|
79
|
}; |
|
80
|
}; |
|
81
|
``` |
|
82
|
|
|
83
|
## Troubleshooting |
|
84
|
|
|
85
|
### User Cannot See the Application |
|
86
|
|
|
87
|
1. Verify host configuration allows all hosts |
|
88
|
2. Confirm binding to `0.0.0.0` on port 5000 |
|
89
|
3. Restart workflow after configuration changes |
|
90
|
4. Check console logs for startup errors |
|
91
|
|
|
92
|
### Hot Reload Not Working |
|
93
|
|
|
94
|
1. Check for errors in terminal output |
|
95
|
2. Verify Vite/webpack is running in watch mode |
|
96
|
3. Clear browser cache and hard refresh |
|
97
|
|
|
98
|
### Build Errors |
|
99
|
|
|
100
|
- Check for missing dependencies |
|
101
|
- Verify Vue version compatibility with plugins |
|
102
|
- Review TypeScript errors if using Vue with TypeScript |