编译时过滤无效文件

pull/1/head
yutent 2023-03-28 15:41:01 +08:00
parent 22fa35c77d
commit 9da8158ea9
1 changed files with 18 additions and 3 deletions

View File

@ -22,7 +22,9 @@ export default function compile(root = '', dist = '', conf = {}) {
path: it,
ext: parse(it).ext
}))
.filter(it => fs.isfile(it.path))
.filter(it => fs.isfile(it.path) && it.ext !== '')
console.log(list)
let compileFiles = function (currentPage, page, files) {
for (let it of files) {
@ -115,12 +117,19 @@ export default function compile(root = '', dist = '', conf = {}) {
return
}
let idx = list.findIndex(_ => _.path === it)
let name = it.slice(dir.length + 1)
let ext = parse(name).ext
if (ext === '') {
return
}
list.splice(idx, 1)
files.push({
name: it.slice(dir.length + 1),
name,
path: it,
ext: parse(it).ext
ext
})
})
}
@ -137,6 +146,12 @@ export default function compile(root = '', dist = '', conf = {}) {
if (fs.isdir(PUBLIC_DIR)) {
console.log('\n正在处理静态资源 ...')
fs.ls(PUBLIC_DIR, true).forEach(it => {
let ext = parse(it).ext
if (ext === '') {
return
}
if (fs.isfile(it)) {
let name = it.slice(PUBLIC_DIR.length + 1)
console.log(' 复制 %s ...', name)