|
|
|
@ -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`); |
|
|
|
|