push
This commit is contained in:
28
build/less.ts
Normal file
28
build/less.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user