forked from HendrikBorgelt/React_flow_test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
61 lines (53 loc) · 2.12 KB
/
Copy pathvite.config.js
File metadata and controls
61 lines (53 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ── Schema variants ───────────────────────────────────────────────────────────
// Set VITE_SCHEMA to select which schema config to build.
// Valid values: 'chemdcat' (default) | 'coremeta4cat' | 'dcat-ap-plus'
//
// Dev: npm run dev → chemdcat (localhost:5173/)
// VITE_SCHEMA=coremeta4cat npm run dev
// Build: npm run build → chemdcat (dist/chemdcat/)
// npm run build:all → all three variants
const SCHEMA_CONFIGS = {
'chemdcat': {
configFile: 'chemdcat.config.js',
base: '/React_flow_test/chemdcat/',
outDir: 'dist/chemdcat',
},
'coremeta4cat': {
configFile: 'coremeta4cat.config.js',
base: '/React_flow_test/coremeta4cat/',
outDir: 'dist/coremeta4cat',
},
'dcat-ap-plus': {
configFile: 'dcat-ap-plus.config.js',
base: '/React_flow_test/dcat-ap-plus/',
outDir: 'dist/dcat-ap-plus',
},
};
export default defineConfig(({ command, mode }) => {
// loadEnv reads .env files AND process.env (including CI variables)
const env = loadEnv(mode, process.cwd(), '');
const key = env.VITE_SCHEMA ?? 'chemdcat';
const sc = SCHEMA_CONFIGS[key] ?? SCHEMA_CONFIGS['chemdcat'];
return {
plugins: [react()],
// In dev, serve from root; in production use the schema-specific sub-path.
base: command === 'serve' ? '/' : sc.base,
// `~config` resolves to the active schema's config file at build time.
// This ensures only one schema's assets are bundled per build.
resolve: {
alias: {
'~config': path.resolve(__dirname, 'src', 'configs', sc.configFile),
},
},
publicDir: false, // docs files are copied by scripts/copy-docs.mjs
build: {
outDir: sc.outDir,
emptyOutDir: true,
},
};
});