pull/1/head
yutent 2022-10-14 12:06:33 +08:00
parent a4841af052
commit 5e6fc26bd3
1 changed files with 11 additions and 2 deletions

View File

@ -8,7 +8,7 @@ const noc = Buffer.from('')
export default function compile(root = '', dist = '', conf = {}) { export default function compile(root = '', dist = '', conf = {}) {
// //
const IS_MPA = Object.keys(conf.pages).length > 1 const IS_MPA = Object.keys(conf.pages).length > 1
let timeStart = Date.now()
let html = fs.cat(join(process.env.PWD, 'index.html')).toString() let html = fs.cat(join(process.env.PWD, 'index.html')).toString()
let pagesDir = '', let pagesDir = '',
@ -26,6 +26,8 @@ export default function compile(root = '', dist = '', conf = {}) {
currentPage = Object.keys(conf.pages)[0] currentPage = Object.keys(conf.pages)[0]
page = conf.pages[currentPage] page = conf.pages[currentPage]
console.log('正在生成 %s...', `${currentPage}.html`)
for (let it of list) { for (let it of list) {
// 入口文件, 特殊处理 // 入口文件, 特殊处理
if (it.path === page.entry) { if (it.path === page.entry) {
@ -35,10 +37,11 @@ export default function compile(root = '', dist = '', conf = {}) {
let code = parseHtml(html, { page, imports: conf.imports, entry }) let code = parseHtml(html, { page, imports: conf.imports, entry })
fs.echo(code, join(dist, `${currentPage}.html`)) fs.echo(code, join(dist, `${currentPage}.html`))
continue continue
} }
console.log(' 解析 %s...', it.name)
switch (it.ext) { switch (it.ext) {
case '.vue': case '.vue':
{ {
@ -80,7 +83,13 @@ export default function compile(root = '', dist = '', conf = {}) {
fs.echo(code, join(dist, it.name)) fs.echo(code, join(dist, it.name))
} }
break break
default:
fs.cp(it.path, join(dist, it.name))
break
} }
} }
} }
console.log('\n页面处理完成, 耗时 %ss\n', (Date.now() - timeStart) / 1000)
} }