Browse Source

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

Merge in VISUAL/fineui from ~ZHENFEI.LI/fineui:master to master

* commit '208974fc15cb4d0970d4fdb40f821b080e4ef716':
  KERNEL-10608 refactor: 使用withoutNormalize的less
  KERNEL-10608 refactor: 不额外放图片包
  KERNEL-10608 feat: fineui打包出fineui.less以供用户在外部定制主题
es6
Zhenfei.Li 3 years ago
parent
commit
439660caa1
  1. 5
      .npmignore
  2. 35
      lib/prepublish/prepublish.js

5
.npmignore

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

35
lib/prepublish/prepublish.js

@ -1,5 +1,7 @@
const { resolve } = require("path");
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;
@ -27,3 +29,34 @@ 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 finalizeCompile() {
let lessContent = '';
bundleWithoutNormalize.forEach(path => {
lessContent += `@import "../.${path}";\n`;
});
writeFileSync(
join(lessPath, 'fineui.less'),
lessContent,
);
}
removeFiles(`${lessPath}/font`);
removeFiles(`${lessPath}/fineui.less`);
finalizeCompile();
copyFiles(`${process.cwd()}/dist/font`, lessPath);

Loading…
Cancel
Save