2022-08-26 14:49:44 +02:00
|
|
|
import { defineConfig, mergeConfig } from 'vite';
|
|
|
|
import {
|
|
|
|
configDefaults,
|
|
|
|
defineConfig as vitestDefineConfig,
|
|
|
|
} from 'vitest/config';
|
2022-05-05 17:15:22 +02:00
|
|
|
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
|
|
|
|
2022-08-26 14:49:44 +02:00
|
|
|
const vitestConfig = vitestDefineConfig({
|
2022-05-05 17:15:22 +02:00
|
|
|
test: {
|
|
|
|
globals: true,
|
|
|
|
setupFiles: 'src/setupTests.ts',
|
|
|
|
environment: 'jsdom',
|
|
|
|
exclude: [...configDefaults.exclude, '**/cypress/**'],
|
|
|
|
},
|
2024-11-06 12:55:44 +01:00
|
|
|
css: {
|
|
|
|
preprocessorOptions: {
|
|
|
|
scss: {
|
|
|
|
api: 'modern-compiler'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-26 14:49:44 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
export default mergeConfig(
|
|
|
|
defineConfig({
|
|
|
|
base: UNLEASH_BASE_PATH,
|
|
|
|
build: {
|
|
|
|
outDir: 'build',
|
|
|
|
assetsDir: 'static',
|
2024-01-04 11:11:42 +01:00
|
|
|
assetsInlineLimit: 0,
|
2023-01-24 20:40:03 +01:00
|
|
|
modulePreload: false,
|
2023-08-17 15:04:41 +02:00
|
|
|
cssCodeSplit: false,
|
2022-08-26 14:49:44 +02:00
|
|
|
},
|
|
|
|
server: {
|
|
|
|
open: true,
|
|
|
|
host: true,
|
|
|
|
port: 3000,
|
|
|
|
proxy: {
|
|
|
|
[`${UNLEASH_BASE_PATH}api`]: {
|
|
|
|
target: UNLEASH_API,
|
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
[`${UNLEASH_BASE_PATH}auth`]: {
|
|
|
|
target: UNLEASH_API,
|
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
[`${UNLEASH_BASE_PATH}logout`]: {
|
|
|
|
target: UNLEASH_API,
|
|
|
|
changeOrigin: true,
|
|
|
|
},
|
2022-09-30 13:01:32 +02:00
|
|
|
[`${UNLEASH_BASE_PATH}health`]: {
|
|
|
|
target: UNLEASH_API,
|
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
[`${UNLEASH_BASE_PATH}invite`]: {
|
|
|
|
target: UNLEASH_API,
|
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
[`${UNLEASH_BASE_PATH}edge`]: {
|
|
|
|
target: UNLEASH_API,
|
|
|
|
changeOrigin: true,
|
|
|
|
},
|
2022-05-05 17:15:22 +02:00
|
|
|
},
|
2022-12-05 17:21:59 +01:00
|
|
|
fs: {
|
|
|
|
allow: ['..'],
|
|
|
|
},
|
2022-05-05 17:15:22 +02:00
|
|
|
},
|
2022-08-26 14:49:44 +02:00
|
|
|
plugins: [react(), tsconfigPaths(), svgr(), envCompatible()],
|
|
|
|
esbuild: {
|
|
|
|
logOverride: { 'this-is-undefined-in-esm': 'silent' },
|
|
|
|
},
|
|
|
|
}),
|
2023-10-02 14:25:46 +02:00
|
|
|
vitestConfig,
|
2022-08-26 14:49:44 +02:00
|
|
|
);
|