diff --git a/.npmignore b/.npmignore index 54bd43012..e0847049f 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,5 @@ * +!public/less/*.less !src/less/**/*.less !dist/lib/*.d.ts !dist/lib/**/*.d.ts diff --git a/lib/prepublish/prepublish.js b/lib/prepublish/prepublish.js index badead82f..5a8f9034e 100644 --- a/lib/prepublish/prepublish.js +++ b/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`);