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