Add experimental feature flag 'styles_with_tokens'

This commit is contained in:
diondiondion 2025-11-11 11:31:10 +01:00
parent b43144db31
commit a23163caba

View File

@ -140,7 +140,14 @@ async function loadThemesFromConfig(root: string) {
console.warn(`Invalid theme path "${themePath}" in themes.yml, skipping`); console.warn(`Invalid theme path "${themePath}" in themes.yml, skipping`);
continue; continue;
} }
themes[themeName] = themePath;
let mappedThemePath: string = themePath;
if (isStylesWithTokensEnabled()) {
mappedThemePath = themePath.replace('styles/', 'styles_new/');
}
themes[themeName] = mappedThemePath;
} }
if (Object.keys(themes).length === 0) { if (Object.keys(themes).length === 0) {
@ -163,3 +170,13 @@ function isThemeFile(file: string, themes: Themes) {
const basename = pathToThemeName(file); const basename = pathToThemeName(file);
return basename in themes; return basename in themes;
} }
function isStylesWithTokensEnabled() {
// Read the ENV at plugin initialization time
const raw = process.env.EXPERIMENTAL_FEATURES ?? '';
const features = raw
.split(',')
.map((s) => s.trim())
.filter(Boolean);
return features.includes('styles_with_tokens');
}