You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
674 B

7 months ago
import { getThemeVariables } from 'ant-design-vue/dist/theme';
import lessToJs from 'less-vars-to-js';
import fs from 'fs';
function getVariablesByPath(paths: string[]) {
let modifyVars = {};
paths.forEach((path) => {
const paletteLess = fs.readFileSync(path, 'utf8');
modifyVars = Object.assign(
modifyVars,
lessToJs(paletteLess, { stripPrefix: true, resolveVariables: false })
);
});
return modifyVars;
}
export function generateModifyVars({
dark = false,
paths = [],
}: {
dark: boolean;
paths: string[];
}) {
const modifyVars = getThemeVariables({ dark });
return {
...modifyVars,
...getVariablesByPath(paths),
};
}