Skip to content

Commit 201024e

Browse files
updated to use env for ai url
1 parent 3c6c9c8 commit 201024e

1 file changed

Lines changed: 95 additions & 92 deletions

File tree

vite.config.ts

Lines changed: 95 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig, type PluginOption } from 'vite';
1+
import { defineConfig, type PluginOption, loadEnv } from 'vite';
22
import react from '@vitejs/plugin-react';
33
import importMetaUrlPlugin from '@codingame/esbuild-import-meta-url-plugin';
44
import { visualizer } from "rollup-plugin-visualizer";
@@ -8,102 +8,105 @@ import { resolve } from 'path';
88
import flowbiteReact from "flowbite-react/plugin/vite";
99

1010
// https://vite.dev/config/
11-
export default defineConfig({
12-
base: './',
13-
esbuild: {
14-
sourcemap: true,
15-
supported: {
16-
'top-level-await': true,
17-
},
18-
},
19-
define: {
20-
rootDirectory: JSON.stringify(__dirname)
21-
},
22-
plugins: [react(), visualizer() as PluginOption, viteStaticCopy({
23-
targets: [
24-
{
25-
src: 'node_modules/flexlayout-react/style',
26-
dest: './node_modules/flexlayout-react/'
27-
},
28-
{
29-
src: 'node_modules/gridstack/dist/gridstack.css',
30-
dest: './node_modules/gridstack/dist/'
31-
} ]
32-
}), flowbiteReact()],
33-
resolve: {
34-
alias: [
35-
{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
36-
{
37-
find: '@components',
38-
replacement: fileURLToPath(new URL('./src/components', import.meta.url)),
39-
},
40-
{
41-
find: '@connections',
42-
replacement: fileURLToPath(new URL('./src/connections', import.meta.url)),
43-
},
44-
{
45-
find: '@utils',
46-
replacement: fileURLToPath(new URL('./src/utils', import.meta.url)),
11+
export default defineConfig(({ mode }) => {
12+
const env = loadEnv(mode, process.cwd(), '');
13+
return {
14+
base: './',
15+
esbuild: {
16+
sourcemap: true,
17+
supported: {
18+
'top-level-await': true,
4719
},
48-
{
49-
find: '@assets',
50-
replacement: fileURLToPath(new URL('./src/assets', import.meta.url)),
51-
},
52-
],
53-
},
54-
worker: {
55-
format: 'es',
56-
},
57-
optimizeDeps: {
58-
esbuildOptions: {
59-
tsconfig: './tsconfig.json',
60-
plugins: [
61-
importMetaUrlPlugin
20+
},
21+
define: {
22+
rootDirectory: JSON.stringify(__dirname)
23+
},
24+
plugins: [react(), visualizer() as PluginOption, viteStaticCopy({
25+
targets: [
26+
{
27+
src: 'node_modules/flexlayout-react/style',
28+
dest: './node_modules/flexlayout-react/'
29+
},
30+
{
31+
src: 'node_modules/gridstack/dist/gridstack.css',
32+
dest: './node_modules/gridstack/dist/'
33+
} ]
34+
}), flowbiteReact()],
35+
resolve: {
36+
alias: [
37+
{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
38+
{
39+
find: '@components',
40+
replacement: fileURLToPath(new URL('./src/components', import.meta.url)),
41+
},
42+
{
43+
find: '@connections',
44+
replacement: fileURLToPath(new URL('./src/connections', import.meta.url)),
45+
},
46+
{
47+
find: '@utils',
48+
replacement: fileURLToPath(new URL('./src/utils', import.meta.url)),
49+
},
50+
{
51+
find: '@assets',
52+
replacement: fileURLToPath(new URL('./src/assets', import.meta.url)),
53+
},
6254
],
6355
},
64-
},
65-
server: {
66-
port: 3000,
67-
proxy: {
68-
'/api': 'https://xrp-code-d-u01.wpi.edu'
69-
}
70-
},
71-
build: {
72-
minify: 'esbuild',
73-
rollupOptions: {
74-
input: {
75-
main: resolve(__dirname, 'index.html'),
56+
worker: {
57+
format: 'es',
58+
},
59+
optimizeDeps: {
60+
esbuildOptions: {
61+
tsconfig: './tsconfig.json',
62+
plugins: [
63+
importMetaUrlPlugin
64+
],
7665
},
77-
output: {
78-
manualChunks(id: string) {
79-
if (id.includes('react-blockly')) {
80-
return '@react-blockly'
81-
}
82-
if (id.includes('@codingame')) {
83-
return '@codingame'
84-
}
85-
if (
86-
id.includes('react') ||
87-
id.includes('flexlayout-react') ||
88-
id.includes('react-arborist') ||
89-
id.includes('react-dom') ||
90-
id.includes('react-hotkeys-hook') ||
91-
id.includes('eact-i18next') ||
92-
id.includes('react-icons') ||
93-
id.includes('react-xtermjs')
94-
) {
95-
return '@react'
96-
}
97-
if (
98-
id.includes('monaco-languageclient') ||
99-
id.includes('@typefox/pyright-browser') ||
100-
id.includes('monaco-editor')
101-
) {
102-
return '@monaco'
66+
},
67+
server: {
68+
port: 3000,
69+
proxy: {
70+
'/api': env.AI_URL
71+
}
72+
},
73+
build: {
74+
minify: 'esbuild',
75+
rollupOptions: {
76+
input: {
77+
main: resolve(__dirname, 'index.html'),
78+
},
79+
output: {
80+
manualChunks(id: string) {
81+
if (id.includes('react-blockly')) {
82+
return '@react-blockly'
83+
}
84+
if (id.includes('@codingame')) {
85+
return '@codingame'
86+
}
87+
if (
88+
id.includes('react') ||
89+
id.includes('flexlayout-react') ||
90+
id.includes('react-arborist') ||
91+
id.includes('react-dom') ||
92+
id.includes('react-hotkeys-hook') ||
93+
id.includes('eact-i18next') ||
94+
id.includes('react-icons') ||
95+
id.includes('react-xtermjs')
96+
) {
97+
return '@react'
98+
}
99+
if (
100+
id.includes('monaco-languageclient') ||
101+
id.includes('@typefox/pyright-browser') ||
102+
id.includes('monaco-editor')
103+
) {
104+
return '@monaco'
105+
}
103106
}
104107
}
105108
}
106-
}
107-
},
108-
envPrefix: ['VITE_', 'GOOGLE_'],
109+
},
110+
envPrefix: ['VITE_', 'GOOGLE_'],
111+
}
109112
});

0 commit comments

Comments
 (0)