-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathvite.config.ts
115 lines (111 loc) · 3.28 KB
/
vite.config.ts
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
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,
},
'/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: {
requiredVersion: dependencies.react,
singleton: true,
},
'react-dom': {
requiredVersion: dependencies['react-dom'],
singleton: true,
},
'styled-components': {
requiredVersion: dependencies['styled-components'],
singleton: true,
},
},
runtimePlugins: ['./src/remote/custom-runtime-plugin'],
}),
react(),
],
build: {
target: 'chrome89',
},
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)) },
],
},
})
}