Browse Source

KERNEL-10608 feat: fineui打包出fineui.less以供用户在外部定制主题

es6
Zhenfei.Li 3 years ago
parent
commit
90688a68b5
  1. 3
      .npmignore
  2. BIN
      dist/images/1x/icon/auto_normal.png
  3. BIN
      dist/images/1x/icon/auto_select.png
  4. BIN
      dist/images/1x/icon/dark/trans_disable.png
  5. BIN
      dist/images/2x/background/trans_disable.png
  6. BIN
      dist/images/2x/icon/dark/trans_disable.png
  7. 50
      lib/prepublish/prepublish.js

3
.npmignore

@ -1,7 +1,4 @@
*
!src/less/*.less
!src/less/lib/*.less
!src/less/resource/*.less
!dist/lib/*.d.ts
!dist/lib/**/*.d.ts
!dist/font.css

BIN
dist/images/1x/icon/auto_normal.png vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
dist/images/1x/icon/auto_select.png vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
dist/images/1x/icon/dark/trans_disable.png vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

BIN
dist/images/2x/background/trans_disable.png vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

BIN
dist/images/2x/icon/dark/trans_disable.png vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

50
lib/prepublish/prepublish.js

@ -1,5 +1,6 @@
const { resolve } = require("path");
const { writeFileSync } = require("fs");
const { resolve, relative, join } = require("path");
const { writeFileSync, readdirSync, statSync } = require("fs");
const { spawnSync } = require('child_process');
function pad2(n) {// always returns a string
return (n < 10 ? "0" : "") + n;
@ -27,3 +28,48 @@ packageJSON.publishConfig.registry = 'https://npm.fineres.com/';
packageJSON.name = "@fui/core";
writeFileSync(resolve(__dirname, "../../package.json"), JSON.stringify(packageJSON, null, 2));
// 将less打包成fineui.less发布到npm以供用户定制主题
const lessPath = join(process.cwd(), '/src/less');
function copyFiles(from, to) {
spawnSync('cp', ['-r', from, to]);
}
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() {
const componentsLessContent = readDirSync(lessPath);
writeFileSync(
join(lessPath, 'fineui.less'),
componentsLessContent,
);
}
removeFiles(`${lessPath}/images`);
removeFiles(`${lessPath}/font`);
removeFiles(`${lessPath}/fineui.less`);
finalizeCompile();
copyFiles(`${process.cwd()}/dist/images`, lessPath);
copyFiles(`${process.cwd()}/dist/font`, lessPath);

Loading…
Cancel
Save