Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// site less file
mainLessFile: path.join(root, './src/styles.less'),
themeVariables: [
'@primary-color',
'@text-color',
'@text-color-secondary'
],
// if provided, file will be created with generated less/styles
outputFilePath
}
if (fs.existsSync(outputFilePath)) {
fs.unlinkSync(outputFilePath);
}
generateTheme(options).then(less => {
console.log('Theme generated successfully');
})
.catch(error => {
console.log('Error', error);
})
@import './theme/styles/app/index';
@import './abc/index';
@import '../src/app/styles/index.less';
`;
fs.writeFileSync(path.resolve(root, '.tmp/all.less'), allLess);
const options = {
antdStylesDir: path.join(root, 'node_modules/ng-zorro-antd/src/'),
stylesDir: path.join(root, '.tmp'),
// varFile: path.join(__dirname, '../components/style/themes/default.less'),
themeVariables: ['@primary-color'],
mainLessFile: path.join(root, '.tmp/all.less'),
outputFilePath: path.join(root, 'src/assets/color.less'),
};
generateTheme(options);
fs.writeFileSync(tmpVarFilePath, ALLVAR);
}
function removeVarFile() {
fs.unlinkSync(tmpVarFilePath);
}
function removeOutputFile() {
if (fs.existsSync(outputFilePath)) {
fs.unlinkSync(outputFilePath);
}
}
genVarFile();
removeOutputFile();
generateTheme(options)
.then(() => {
removeVarFile();
console.log('Theme generated successfully');
})
.catch(error => {
removeVarFile();
console.log('Error', error);
});
mainLessFile: path.join(__dirname, './src/styles/main.less'),
themeVariables: [
'@primary-color',
'@secondary-color',
'@text-color',
'@text-color-secondary',
'@heading-color',
'@layout-body-background',
'@btn-primary-bg',
'@layout-header-background'
],
indexFileName: 'index.html',
outputFilePath: path.join(__dirname, './public/color.less'),
}
generateTheme(options).then(less => {
console.log('Theme generated successfully');
})
.catch(error => {
console.log('Error', error);
});
module.exports = () => generateTheme(options);
#!/usr/bin/env node
const path = require('path');
const { generateTheme } = require('antd-theme-generator');
const options = {
stylesDir: path.join(__dirname, '../site/theme/static'),
antdStylesDir: path.join(__dirname, '../components'),
varFile: path.join(__dirname, '../components/style/themes/default.less'),
mainLessFile: path.join(__dirname, '../site/theme/static/index.less'),
themeVariables: ['@primary-color'],
outputFilePath: path.join(__dirname, '../_site/color.less'),
};
generateTheme(options);
if (!content.match(/\/color\.less/g)) {
index.source = () =>
content.replace(less, "").replace(//gi, `${less}`);
content = index.source();
index.size = () => content.length;
}
}
if (options.generateOnce && this.colors) {
compilation.assets["color.less"] = {
source: () => this.colors,
size: () => this.colors.length
};
return callback();
}
generateTheme(options)
.then(css => {
if (options.generateOnce) {
this.colors = css;
}
compilation.assets["color.less"] = {
source: () => css,
size: () => css.length
};
callback();
})
.catch(err => {
callback(err);
});
});
}