forked from ynput/ayon-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
131 lines (127 loc) · 3.68 KB
/
Copy pathvite.config.ts
File metadata and controls
131 lines (127 loc) · 3.68 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { fileURLToPath, URL } from 'url'
import { federation } from '@module-federation/vite'
import { dependencies } from './package.json'
export default ({ mode }) => {
Object.assign(process?.env, loadEnv(mode, process?.cwd(), ''))
let SERVER_URL = 'http://localhost:5000'
// use .env if valid
if (process?.env?.SERVER_URL) {
SERVER_URL = process.env.SERVER_URL
}
// https://vitejs.dev/config/
return defineConfig({
server: {
proxy: {
'/api': {
target: SERVER_URL,
changeOrigin: true,
},
'/ws': {
target: SERVER_URL,
changeOrigin: true,
ws: true,
},
'^.*/ws$': {
target: SERVER_URL,
changeOrigin: true,
ws: true,
},
'/addons': {
target: SERVER_URL,
changeOrigin: true,
},
'/graphql': {
target: SERVER_URL,
changeOrigin: true,
},
'/graphiql': {
target: SERVER_URL,
changeOrigin: true,
},
'/docs': {
target: SERVER_URL,
changeOrigin: true,
},
'/openapi.json': {
target: SERVER_URL,
changeOrigin: true,
},
'/static': {
target: SERVER_URL,
changeOrigin: true,
},
'/openapi': {
target: SERVER_URL,
changeOrigin: true,
},
},
},
plugins: [
federation({
name: 'host',
remotes: {},
exposes: {},
filename: 'remoteEntry.js',
shared: {
react: {
singleton: true,
requiredVersion: dependencies.react,
},
'react-dom': {
singleton: true,
requiredVersion: dependencies['react-dom'],
},
'@ynput/ayon-react-components': {
singleton: true,
},
},
}),
react(),
],
build: {
target: 'chrome89',
// Disable module preload to prevent hardcoded URLs
modulePreload: false,
// Use hash for better cache invalidation
rollupOptions: {
output: {
// Ensure chunks don't have hardcoded base URLs
manualChunks: undefined,
},
},
},
resolve: {
alias: [
{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
{
find: '@containers',
replacement: fileURLToPath(new URL('./src/containers', import.meta.url)),
},
{ find: '@hooks', replacement: fileURLToPath(new URL('./src/hooks', import.meta.url)) },
{
find: '@components',
replacement: fileURLToPath(new URL('./src/components', import.meta.url)),
},
{ find: '@api', replacement: fileURLToPath(new URL('./src/api', import.meta.url)) },
{
find: '@types',
replacement: fileURLToPath(new URL('./src/types', import.meta.url)),
},
{
find: '@queries',
replacement: fileURLToPath(new URL('./src/services', import.meta.url)),
},
{ find: '@pages', replacement: fileURLToPath(new URL('./src/pages', import.meta.url)) },
{ find: '@context', replacement: fileURLToPath(new URL('./src/context', import.meta.url)) },
{ find: '@state', replacement: fileURLToPath(new URL('./src/features', import.meta.url)) },
{ find: '@helpers', replacement: fileURLToPath(new URL('./src/helpers', import.meta.url)) },
{
find: '@shared',
replacement: fileURLToPath(new URL('./shared/src', import.meta.url)),
},
],
},
})
}