提交 b4838fdc 编写于 作者: fxy060608's avatar fxy060608

chore: improve log

上级 f397b1fe
export { formatErrMsg, formatInfoMsg, formatWarnMsg } from './format'
type LogType = 'error' | 'warn' | 'info' | 'log'
let lastType: LogType | undefined
let lastMsg: string | undefined
export function output(type: LogType, msg: string) {
if (type === lastType && msg === lastMsg) {
return
}
lastMsg = msg
lastType = type
const method = type === 'info' ? 'log' : type
console[method](msg)
}
import { extend } from '@vue/shared'
import { RollupWatcher } from 'rollup'
import { BuildOptions, createLogger, ServerOptions } from 'vite'
import { M } from '@dcloudio/uni-cli-shared'
import { M, output } from '@dcloudio/uni-cli-shared'
import { CliOptions } from '.'
import { build, buildSSR } from './build'
import { createServer, createSSRServer } from './server'
......@@ -30,25 +30,26 @@ export async function runDev(options: CliOptions & ServerOptions) {
if (isFirstStart) {
return (isFirstStart = false)
}
console.log(M['dev.watching.start'])
output('log', M['dev.watching.start'])
} else if (event.code === 'BUNDLE_END') {
event.result.close()
if (isFirstEnd) {
// 首次全量同步
return (
(isFirstEnd = false),
console.log(M['dev.watching.end']),
output('log', M['dev.watching.end']),
printStartupDuration(createLogger(options.logLevel), false)
)
}
const files = process.env.UNI_APP_CHANGED_FILES
if (files) {
if (files && !files.includes('app-config-service.js')) {
process.env.UNI_APP_CHANGED_FILES = ''
return console.log(
return output(
'log',
M['dev.watching.end.files'].replace('{files}', files)
)
}
return console.log(M['dev.watching.end'])
return output('log', M['dev.watching.end'])
}
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册