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

feat(x-ios): 增加页面编译进度

上级 921ac8ad
......@@ -4,9 +4,11 @@ import {
APP_CONFIG,
PAGES_JSON_UTS,
normalizeAppPagesJson,
normalizePath,
normalizeUniAppXAppConfig,
normalizeUniAppXAppPagesJson,
parseManifestJsonOnce,
runByHBuilderX,
} from '@dcloudio/uni-cli-shared'
import type { Plugin } from 'vite'
import { isPages } from '../utils'
......@@ -18,6 +20,8 @@ export function uniAppPagesPlugin(): Plugin {
PAGES_JSON_UTS
)
let allPagePaths: string[] = []
let isFirst = true
return {
name: 'uni:app-pages',
apply: 'build',
......@@ -32,9 +36,27 @@ export function uniAppPagesPlugin(): Plugin {
}
},
transform(code, id) {
if (isFirst) {
if (id.endsWith('.uvue')) {
const pagePath = normalizePath(
path.relative(process.env.UNI_INPUT_DIR, id)
).replace('.uvue', '')
const index = allPagePaths.indexOf(pagePath)
if (index > -1) {
console.log(
`当前工程${allPagePaths.length}个页面,正在编译${pagePath}...${
runByHBuilderX() ? '\u200b' : '\r'
}`
)
}
}
}
if (isPages(id)) {
this.addWatchFile(path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'))
const pagesJson = normalizeUniAppXAppPagesJson(code)
allPagePaths = pagesJson.pages.map((p) => p.path)
this.emitFile({
fileName: APP_CONFIG,
type: 'asset',
......@@ -49,5 +71,8 @@ export function uniAppPagesPlugin(): Plugin {
}
}
},
buildEnd() {
isFirst = false
},
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册