style: optimize packaging code

This commit is contained in:
就眠儀式 2022-02-17 10:27:15 +08:00
parent 229f2da5fe
commit e64697a99b

View File

@ -1,25 +1,19 @@
/** var fs = require('fs');
* merge less file var { resolve } = require('path');
* <p>
*/
var fs = require('fs');
var { resolve } = require('path');
const inputDir = resolve(__dirname, './src/component') const inputDir = resolve(__dirname, './src/component')
const inputsArray = fs.readdirSync(inputDir).filter((name) => { const inputsArray = fs.readdirSync(inputDir).filter((name) => {
const componentDir = resolve(inputDir, name) const componentDir = resolve(inputDir, name);
const isDir = fs.lstatSync(componentDir).isDirectory() const isDir = fs.lstatSync(componentDir).isDirectory();
return isDir && fs.readdirSync(componentDir).includes('index.ts') return isDir && fs.readdirSync(componentDir).includes('index.ts');
}) });
// 读取基础变量 与 公共样式
var content = fs.readFileSync("./src/theme/variable.less").toString() + '\n\n';
content += fs.readFileSync("./src/theme/index.less").toString() + '\n\n';
// 组件样式 var content = fs.readFileSync("./src/theme/variable.less").toString() + '\n\n';
inputsArray.forEach(function (f) { content += fs.readFileSync("./src/theme/index.less").toString() + '\n\n';
var path = "./src/component/" + f + "/index.less";
inputsArray.forEach(function (f) {
var path = "./src/component/" + f + "/index.less";
fs.exists(path,function(exists){ fs.exists(path,function(exists){
if(exists){ if(exists){
var c = fs.readFileSync(path); var c = fs.readFileSync(path);
@ -29,4 +23,4 @@
fs.writeFileSync('./lib/index.less',content); fs.writeFileSync('./lib/index.less',content);
} }
}); });
}) })