优化编译参数
parent
45ac8e8b3d
commit
73ff200b87
7
index.js
7
index.js
|
@ -22,7 +22,10 @@ const NODE_VERSION = process.versions.node.split('.').map(n => +n)
|
|||
|
||||
let args = process.argv.slice(2)
|
||||
let mode = args.shift() || 'prod'
|
||||
let clean = args.shift() !== '--no-clean'
|
||||
let clean, verbose
|
||||
args = args.join(' ')
|
||||
clean = args.includes('--no-clean') //
|
||||
verbose = args.includes('--verbose') //
|
||||
|
||||
if (NODE_VERSION[0] < 16 || (NODE_VERSION[0] === 16 && NODE_VERSION[1] < 6)) {
|
||||
console.log(red('Error: 你当前的环境不满足 fite 构建工具的要求'))
|
||||
|
@ -57,7 +60,7 @@ switch (mode) {
|
|||
if (clean && fs.isdir(dist)) {
|
||||
fs.rm(dist)
|
||||
}
|
||||
compile(WORK_SPACE, dist, conf.default)
|
||||
compile(WORK_SPACE, dist, conf.default, verbose)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
|
|
|
@ -8,7 +8,7 @@ function readFile(file) {
|
|||
return (file && fs.cat(file)?.toString()) || ''
|
||||
}
|
||||
|
||||
export default function compile(root = '', dist = '', conf = {}) {
|
||||
export default function compile(root = '', dist = '', conf = {}, verbose) {
|
||||
//
|
||||
const SOURCE_DIR = join(root, 'src')
|
||||
const PUBLIC_DIR = join(root, 'public')
|
||||
|
@ -82,7 +82,7 @@ export default function compile(root = '', dist = '', conf = {}) {
|
|||
continue
|
||||
}
|
||||
|
||||
page === null && console.log(' 解析 %s ...', it.name)
|
||||
verbose && console.log(' 解析 %s ...', it.name)
|
||||
|
||||
let pageDir = IS_MPA && currentPage ? `pages/${currentPage}` : ''
|
||||
|
||||
|
@ -148,11 +148,12 @@ export default function compile(root = '', dist = '', conf = {}) {
|
|||
|
||||
if (fs.isfile(it)) {
|
||||
let name = it.slice(PUBLIC_DIR.length + 1)
|
||||
console.log(' 复制 %s ...', name)
|
||||
verbose && console.log(' 复制 %s ...', name)
|
||||
fs.cp(it, join(dist, name))
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log('')
|
||||
|
||||
for (let currentPage in conf.pages) {
|
||||
let page = conf.pages[currentPage]
|
||||
|
|
Loading…
Reference in New Issue