Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
80
frontend/vite.config.ts
Normal file
80
frontend/vite.config.ts
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
import { defineConfig } from 'vitest/config';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
import fs from 'fs';
|
||||
|
||||
// Get version from environment, git tag, or package.json
|
||||
function getVersion(): string {
|
||||
// 1. Environment variable (set by GitHub Actions)
|
||||
if (process.env.VERSION) {
|
||||
return process.env.VERSION;
|
||||
}
|
||||
|
||||
// 2. Try git tag
|
||||
try {
|
||||
const gitTag = execSync('git describe --tags --exact-match 2>/dev/null || git describe --tags 2>/dev/null || echo ""', { encoding: 'utf8' }).trim();
|
||||
if (gitTag) {
|
||||
return gitTag;
|
||||
}
|
||||
} catch {
|
||||
// Git not available or no tags
|
||||
}
|
||||
|
||||
// 3. Fall back to package.json version
|
||||
try {
|
||||
const pkg = JSON.parse(
|
||||
fs.readFileSync(path.resolve(import.meta.dirname, 'package.json'), 'utf8')
|
||||
);
|
||||
if (pkg.version && pkg.version !== '0.0.0') {
|
||||
return pkg.version;
|
||||
}
|
||||
} catch {
|
||||
// package.json not readable
|
||||
}
|
||||
|
||||
return 'dev';
|
||||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ command }) => ({
|
||||
base: command === 'build' ? '/management-assets/' : '/',
|
||||
plugins: [react()],
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(getVersion())
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(import.meta.dirname, './src')
|
||||
}
|
||||
},
|
||||
css: {
|
||||
modules: {
|
||||
localsConvention: 'camelCase',
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
||||
},
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
additionalData: `@use "@/styles/variables.scss" as *;`
|
||||
}
|
||||
}
|
||||
},
|
||||
server: {
|
||||
host: '127.0.0.1',
|
||||
proxy: {
|
||||
'/v0': {
|
||||
target: 'http://127.0.0.1:8317',
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
},
|
||||
test: {
|
||||
env: {
|
||||
TZ: 'UTC'
|
||||
}
|
||||
},
|
||||
build: {
|
||||
target: 'es2020',
|
||||
outDir: 'dist'
|
||||
}
|
||||
}));
|
||||
Loading…
Reference in a new issue