Browse Source

KERNEL-10608 refactor: 使用withoutNormalize的less

es6
Zhenfei.Li 3 years ago
parent
commit
208974fc15
  1. 1
      .npmignore
  2. 31
      lib/prepublish/prepublish.js

1
.npmignore

@ -1,4 +1,5 @@
*
!public/less/*.less
!src/less/**/*.less
!dist/lib/*.d.ts
!dist/lib/**/*.d.ts

31
lib/prepublish/prepublish.js

@ -1,6 +1,7 @@
const { resolve, relative, join } = require("path");
const { writeFileSync, readdirSync, statSync } = require("fs");
const { resolve, join } = require("path");
const { writeFileSync } = require("fs");
const { spawnSync } = require('child_process');
const { bundleWithoutNormalize } = require('../../webpack/attachments');
function pad2(n) {// always returns a string
return (n < 10 ? "0" : "") + n;
@ -40,38 +41,22 @@ function removeFiles(src) {
spawnSync('rm', ['-rf', src]);
}
function readDirSync(directoryPath) {
let content = '';
const pa = readdirSync(directoryPath);
pa.forEach(file => {
const filePath = `${directoryPath}/${file}`;
const info = statSync(filePath);
if (info.isDirectory()) {
content += readDirSync(filePath);
} else {
content += `@import "./${relative(lessPath, filePath)}";\n`;
}
});
return content;
}
function finalizeCompile() {
let componentsLessContent = readDirSync(lessPath);
let lessContent = '';
componentsLessContent += `@import "./public.less";\n`;
bundleWithoutNormalize.forEach(path => {
lessContent += `@import "../.${path}";\n`;
});
writeFileSync(
join(lessPath, 'fineui.less'),
componentsLessContent,
lessContent,
);
}
removeFiles(`${lessPath}/font`);
removeFiles(`${lessPath}/public.less`);
removeFiles(`${lessPath}/fineui.less`);
finalizeCompile();
copyFiles(`${process.cwd()}/dist/font`, lessPath);
copyFiles(`${process.cwd()}/public/less/var.less`, `${lessPath}/public.less`);

Loading…
Cancel
Save