From a23163caba89a02e515fb0be44b2c6666a4c96ca Mon Sep 17 00:00:00 2001 From: diondiondion Date: Tue, 11 Nov 2025 11:31:10 +0100 Subject: [PATCH] Add experimental feature flag 'styles_with_tokens' --- config/vite/plugin-mastodon-themes.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/config/vite/plugin-mastodon-themes.ts b/config/vite/plugin-mastodon-themes.ts index 251d2d8e724..a4740ab8a11 100644 --- a/config/vite/plugin-mastodon-themes.ts +++ b/config/vite/plugin-mastodon-themes.ts @@ -140,7 +140,14 @@ async function loadThemesFromConfig(root: string) { console.warn(`Invalid theme path "${themePath}" in themes.yml, skipping`); 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) { @@ -163,3 +170,13 @@ function isThemeFile(file: string, themes: Themes) { const basename = pathToThemeName(file); 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'); +}