-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.js
More file actions
80 lines (77 loc) · 2.3 KB
/
vite.config.js
File metadata and controls
80 lines (77 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
// https://vite.dev/config/
export default defineConfig({
plugins: [vue()],
publicDir: 'static',
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'scss': fileURLToPath(new URL('./src/assets/scss', import.meta.url))
}
},
server: {
port: 8080,
host: '0.0.0.0',
proxy: {
'/tt': {
target: process.env.TIMETRACKER_URL || 'http://localhost:3000',
changeOrigin: true,
secure: false,
configure: (proxy) => {
proxy.on('proxyRes', function (proxyRes) {
delete proxyRes.headers.host
let cookie = proxyRes.headers['set-cookie']
if (cookie) {
const addCookiePath = (c) => {
if (c.indexOf('path=') < 0) {
return c.trim() + '; path=/'
} else {
return c.replace(/;\s*path=[^;]+/, '; path=/')
}
}
cookie = Array.isArray(cookie) ? cookie.map(addCookiePath) : addCookiePath(cookie)
proxyRes.headers['set-cookie'] = cookie
}
})
proxy.on('error', function (err, _req, res) {
console.error('Proxy error:', err.message)
if (!res.headersSent) {
res.writeHead(502, { 'Content-Type': 'application/json' })
res.end(JSON.stringify({
error: 'Bad Gateway',
message: 'Unable to connect to timetracker backend'
}))
}
})
}
}
}
},
build: {
outDir: 'dist',
assetsDir: 'static',
sourcemap: true,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules/vue') || id.includes('node_modules/vue-router') || id.includes('node_modules/pinia') || id.includes('node_modules/axios')) {
return 'vendor'
}
if (id.includes('node_modules/bootstrap')) {
return 'bootstrap'
}
}
}
}
},
css: {
preprocessorOptions: {
scss: {
api: 'modern',
silenceDeprecations: ['legacy-js-api', 'import', 'global-builtin', 'color-functions', 'abs-percent']
}
}
}
})