Skip to content

Commit

Permalink
fix(web): 修复 HBuilderX 中预编译器安装
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Jan 2, 2025
1 parent 1019ab1 commit b071180
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/vite-plugin-uni/src/cli/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import { initEasycom } from '../utils/easycom'
import { runUVueAndroidBuild, runUVueAndroidDev } from './uvue'
import type { FSWatcher } from 'chokidar'
import { initLogger } from '../configResolved'

export async function runDev(options: CliOptions & ServerOptions) {
extend(options, {
Expand Down Expand Up @@ -178,7 +179,13 @@ export async function runBuild(options: CliOptions & BuildOptions) {
process.exit(0)
}
} catch (e: any) {
console.error(e.message || e)
if (isInHBuilderX()) {
initLogger({
logger: createLogger(options.logLevel),
}).error(e.message || e)
} else {
console.error(e.message || e)
}
console.error(`Build failed with errors.`)
process.exit(1)
}
Expand Down
8 changes: 6 additions & 2 deletions packages/vite-plugin-uni/src/configResolved/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Plugin, ResolvedConfig } from 'vite'
import type { Logger, Plugin } from 'vite'
import { extend, isString } from '@vue/shared'
import {
checkUpdate,
Expand Down Expand Up @@ -53,7 +53,10 @@ function initCheckUpdate() {
export function initLogger({
logger,
nvue,
}: ResolvedConfig & { nvue?: boolean }) {
}: {
logger: Logger
nvue?: boolean
}) {
const { info, warn, error } = logger
logger.info = (msg, opts) => {
msg = formatInfoMsg(msg, extend(opts || {}, { nvue }))
Expand All @@ -73,4 +76,5 @@ export function initLogger({
return error(msg, opts)
}
}
return logger
}

0 comments on commit b071180

Please sign in to comment.