Skip to content

Commit

Permalink
fix: updates the paragon-theme.json output (#2334)
Browse files Browse the repository at this point in the history
* fix: updates the paragon-theme.json output
* fix: typo
  • Loading branch information
adamstankiewicz authored May 29, 2023
1 parent a2ac304 commit faf7dac
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions build-scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,27 @@ const updateParagonThemeOutput = ({
paragonThemeOutput,
name,
isThemeVariant,
isDefaultThemeVariant,
isDarkThemeVariant,
}) => {
if (isThemeVariant) {
paragonThemeOutput.themeUrls.variants = {
...paragonThemeOutput.themeUrls.variants,
[name]: {
default: `./${name}.css`,
minified: `./${name}.min.css`,
paths: {
default: `./${name}.css`,
minified: `./${name}.min.css`,
},
default: isDefaultThemeVariant,
dark: isDarkThemeVariant,
},
};
} else {
paragonThemeOutput.themeUrls[name] = {
default: `./${name}.css`,
minified: `./${name}.min.css`,
paths: {
default: `./${name}.css`,
minified: `./${name}.min.css`,
},
};
}
return paragonThemeOutput;
Expand All @@ -61,6 +69,8 @@ const compileAndWriteStyleSheets = ({
stylesPath,
outDir,
isThemeVariant = false,
isDefaultThemeVariant = true,
isDarkThemeVariant = false,
}) => {
const compiledStyleSheet = sass.compile(stylesPath, {
importers: [{
Expand Down Expand Up @@ -93,13 +103,17 @@ const compileAndWriteStyleSheets = ({
paragonThemeOutput: initialConfigOutput,
name,
isThemeVariant,
isDefaultThemeVariant,
isDarkThemeVariant,
});
} else {
const existingParagonThemeOutput = JSON.parse(fs.readFileSync(`${outDir}/${paragonThemeOutputFilename}`, 'utf8'));
paragonThemeOutput = updateParagonThemeOutput({
paragonThemeOutput: existingParagonThemeOutput,
name,
isThemeVariant,
isDefaultThemeVariant,
isDarkThemeVariant,
});
}
fs.writeFileSync(`${outDir}/${paragonThemeOutputFilename}`, `${JSON.stringify(paragonThemeOutput, null, 2)}\n`);
Expand Down Expand Up @@ -171,6 +185,9 @@ program
stylesPath: `${themesPath}/${themeDir.name}/index.css`,
outDir,
isThemeVariant: true,
isDefaultThemeVariant: themeDir.name === 'light',
// "dark" theme dir does not exist yet, but no harm in having this here
isDarkThemeVariant: themeDir.name === 'dark',
});
});
});
Expand Down

0 comments on commit faf7dac

Please sign in to comment.