2022-05-05 17:15:22 +02:00
|
|
|
import { configDefaults, defineConfig } from 'vitest/config';
|
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
import svgr from 'vite-plugin-svgr';
|
|
|
|
import envCompatible from 'vite-plugin-env-compatible';
|
|
|
|
|
2022-05-19 14:06:18 +02:00
|
|
|
const UNLEASH_API = process.env.UNLEASH_API || 'http://localhost:4242';
|
|
|
|
const UNLEASH_BASE_PATH = process.env.UNLEASH_BASE_PATH || '/';
|
|
|
|
|
|
|
|
if (!UNLEASH_BASE_PATH.startsWith('/') || !UNLEASH_BASE_PATH.endsWith('/')) {
|
|
|
|
console.error('UNLEASH_BASE_PATH must both start and end with /');
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2022-05-05 17:15:22 +02:00
|
|
|
|
|
|
|
export default defineConfig({
|
2022-05-19 14:06:18 +02:00
|
|
|
base: UNLEASH_BASE_PATH,
|
|
|
|
build: {
|
|
|
|
outDir: 'build',
|
|
|
|
assetsDir: 'static',
|
|
|
|
},
|
2022-05-05 17:15:22 +02:00
|
|
|
test: {
|
|
|
|
globals: true,
|
|
|
|
setupFiles: 'src/setupTests.ts',
|
|
|
|
environment: 'jsdom',
|
|
|
|
exclude: [...configDefaults.exclude, '**/cypress/**'],
|
|
|
|
},
|
|
|
|
server: {
|
2022-05-06 13:11:46 +02:00
|
|
|
open: true,
|
2022-06-13 09:25:36 +02:00
|
|
|
host: true,
|
2022-05-05 17:15:22 +02:00
|
|
|
proxy: {
|
2022-05-19 14:06:18 +02:00
|
|
|
[`${UNLEASH_BASE_PATH}api`]: {
|
|
|
|
target: UNLEASH_API,
|
2022-05-05 17:15:22 +02:00
|
|
|
changeOrigin: true,
|
|
|
|
},
|
2022-05-19 14:06:18 +02:00
|
|
|
[`${UNLEASH_BASE_PATH}auth`]: {
|
|
|
|
target: UNLEASH_API,
|
2022-05-05 17:15:22 +02:00
|
|
|
changeOrigin: true,
|
|
|
|
},
|
2022-05-19 14:06:18 +02:00
|
|
|
[`${UNLEASH_BASE_PATH}logout`]: {
|
|
|
|
target: UNLEASH_API,
|
2022-05-05 17:15:22 +02:00
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
plugins: [react(), tsconfigPaths(), svgr(), envCompatible()],
|
|
|
|
});
|