-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #853 from amoutaux/add-env-var-for-backend
feat(web): allow to configure proxy port through env var
- Loading branch information
Showing
1 changed file
with
31 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
import { defineConfig } from 'vite' | ||
import { defineConfig, loadEnv } from 'vite' | ||
import react from '@vitejs/plugin-react-swc' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
base: '/', | ||
plugins: [react()], | ||
assetsInclude: ['**/*.md'], | ||
server: { | ||
port: 8080, | ||
proxy: { | ||
"/api": { | ||
target: "http://localhost:5000", | ||
changeOrigin: true, | ||
secure: false, | ||
}, | ||
"/doc": { | ||
target: "http://localhost:5000", | ||
changeOrigin: true, | ||
secure: false, | ||
export default defineConfig(({ mode }) => { | ||
const env = loadEnv(mode, process.cwd()) | ||
return { | ||
base: '/', | ||
plugins: [react()], | ||
assetsInclude: ['**/*.md'], | ||
server: { | ||
port: 8080, | ||
proxy: { | ||
'/api': { | ||
target: 'http://localhost:' + `${env.VITE_PROXY_PORT ?? '5000'}`, | ||
changeOrigin: true, | ||
secure: false | ||
}, | ||
'/doc': { | ||
target: 'http://localhost:' + `${env.VITE_PROXY_PORT ?? '5000'}`, | ||
changeOrigin: true, | ||
secure: false | ||
} | ||
} | ||
}, | ||
test: { | ||
globals: true, | ||
environment: 'jsdom', | ||
css: true, | ||
reporters: ['verbose'], | ||
coverage: { | ||
reporter: ['text', 'json', 'html'], | ||
include: ['src/**/*'], | ||
exclude: [] | ||
} | ||
} | ||
}, | ||
test: { | ||
globals: true, | ||
environment: 'jsdom', | ||
css: true, | ||
reporters: ['verbose'], | ||
coverage: { | ||
reporter: ['text', 'json', 'html'], | ||
include: ['src/**/*'], | ||
exclude: [], | ||
} | ||
} | ||
}) |