2024-12-31 10:30:14 +05:30
|
|
|
import { reactRouter } from '@react-router/dev/vite';
|
|
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
|
import babel from 'vite-plugin-babel';
|
|
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
|
|
|
import { execSync } from 'node:child_process';
|
2025-01-06 08:14:18 +05:30
|
|
|
import tailwindcss from 'tailwindcss';
|
|
|
|
|
import autoprefixer from 'autoprefixer';
|
2024-03-25 15:34:11 -04:00
|
|
|
|
2024-12-31 10:30:14 +05:30
|
|
|
const prefix = process.env.__INTERNAL_PREFIX || '/admin';
|
2024-11-06 14:29:04 -05:00
|
|
|
if (prefix.endsWith('/')) {
|
2024-12-31 10:30:14 +05:30
|
|
|
throw new Error('Prefix must not end with a slash');
|
2024-11-04 22:05:46 -05:00
|
|
|
}
|
|
|
|
|
|
2024-12-05 02:32:55 -05:00
|
|
|
// Load the version via git tags
|
2024-12-31 10:30:14 +05:30
|
|
|
const version = execSync('git describe --tags --always').toString().trim();
|
2024-12-05 02:32:55 -05:00
|
|
|
if (!version) {
|
2024-12-31 10:30:14 +05:30
|
|
|
throw new Error('Unable to execute git describe');
|
2024-12-05 02:32:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-01-06 08:14:18 +05:30
|
|
|
export default defineConfig({
|
|
|
|
|
base: `${prefix}/`,
|
|
|
|
|
plugins: [reactRouter(), tsconfigPaths()],
|
|
|
|
|
css: {
|
|
|
|
|
postcss: {
|
|
|
|
|
plugins: [tailwindcss, autoprefixer],
|
2024-12-05 02:32:55 -05:00
|
|
|
},
|
2025-01-06 08:14:18 +05:30
|
|
|
},
|
|
|
|
|
define: {
|
|
|
|
|
__VERSION__: JSON.stringify(version),
|
|
|
|
|
},
|
2024-12-31 10:30:14 +05:30
|
|
|
});
|