headplane/vite.config.ts

33 lines
893 B
TypeScript
Raw Normal View History

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';
import tailwindcss from 'tailwindcss';
import autoprefixer from 'autoprefixer';
2024-12-31 10:30:14 +05:30
const prefix = process.env.__INTERNAL_PREFIX || '/admin';
if (prefix.endsWith('/')) {
2024-12-31 10:30:14 +05:30
throw new Error('Prefix must not end with a slash');
}
// Load the version via git tags
2024-12-31 10:30:14 +05:30
const version = execSync('git describe --tags --always').toString().trim();
if (!version) {
2024-12-31 10:30:14 +05:30
throw new Error('Unable to execute git describe');
}
export default defineConfig({
base: `${prefix}/`,
plugins: [reactRouter(), tsconfigPaths()],
css: {
postcss: {
plugins: [tailwindcss, autoprefixer],
},
},
define: {
__VERSION__: JSON.stringify(version),
__PREFIX__: JSON.stringify(prefix),
},
2024-12-31 10:30:14 +05:30
});