Skip to content

Commit

Permalink
feat(uvue): app-android 支持 pug
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Mar 7, 2024
2 parents 7cd6fd9 + 8ec8477 commit 719b642
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 17 deletions.
10 changes: 10 additions & 0 deletions packages/uni-app-uts/src/plugins/android/uvue/sfc/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ export function resolveGenTemplateCodeOptions(
preprocessOptions?: any
}
): TemplateCompilerOptions {
const block = descriptor.template!
const inputRoot = normalizePath(options.rootDir)
const templateStartLine = descriptor.template?.loc.start.line ?? 0
let preprocessOptions = block.lang && options.preprocessOptions
if (block.lang === 'pug') {
preprocessOptions = {
doctype: 'html',
...preprocessOptions,
}
}
return {
...options,
filename: relativeFileName,
inMap: descriptor.template?.map,
preprocessLang: block.lang === 'html' ? undefined : block.lang,
preprocessOptions,
matchEasyCom: (tag, uts) => {
const source = matchEasycom(tag)
if (uts && source) {
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-cli-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@types/hash-sum": "^1.0.0",
"@types/less": "^3.0.3",
"@types/mime": "^2.0.3",
"@types/module-alias": "^2.0.1",
"@types/module-alias": "^2.0.4",
"@types/resolve": "^1.20.2",
"@types/sass": "^1.43.1",
"@types/stylus": "^0.48.36",
Expand Down
30 changes: 23 additions & 7 deletions packages/uni-cli-shared/src/hbx/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,26 @@ export function initModuleAlias() {
}
if (isInHBuilderX()) {
// 又是为了复用 HBuilderX 的插件逻辑,硬编码映射
Object.keys(hbxPlugins).forEach((name) => {
Object.keys(hbxPlugins).forEach((lang) => {
const realPath = path.resolve(
process.env.UNI_HBUILDERX_PLUGINS,
hbxPlugins[lang as keyof typeof hbxPlugins]
)
moduleAlias.addAlias(
name,
path.resolve(
process.env.UNI_HBUILDERX_PLUGINS,
hbxPlugins[name as keyof typeof hbxPlugins]
)
lang,
// @ts-expect-error
() => {
try {
require.resolve(realPath)
} catch (e) {
const msg = moduleAliasFormatter.format(
`Preprocessor dependency "${lang}" not found. Did you install it?`
)
console.error(msg)
process.exit(0)
}
return realPath
}
)
})
// web 平台用了 vite 内置 css 插件,该插件会加载预编译器如scss、less等,需要转向到 HBuilderX 的对应编译器插件
Expand Down Expand Up @@ -109,7 +122,10 @@ export const moduleAliasFormatter: Formatter = {
format(msg) {
let lang = ''
let preprocessor = ''
if (msg.includes(`"sass"`)) {
if (msg.includes(`"pug"`)) {
lang = 'pug'
preprocessor = 'compile-pug-cli'
} else if (msg.includes(`"sass"`)) {
lang = 'sass'
preprocessor = 'compile-dart-sass'
} else if (msg.includes(`"less"`)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-h5-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/debug": "^4.1.7",
"@types/fs-extra": "^9.0.13",
"@types/mime": "^2.0.3",
"@types/module-alias": "^2.0.1",
"@types/module-alias": "^2.0.4",
"@types/resolve": "^1.20.2",
"@vue/compiler-core": "3.3.11",
"esbuild": "^0.17.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-mp-weixin/src/compiler/uniad.app.json.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ module.exports = function (appJson) {
}
if (!appJson.plugins['uni-ad']) {
appJson.plugins['uni-ad'] = {
version: '1.1.10',
version: '1.2.1',
provider: 'wxf72d316417b6767f',
}
}
if (!appJson.plugins['coral-adv']) {
appJson.plugins['coral-adv'] = {
version: '1.0.18',
version: '1.0.24',
provider: 'wx0e203209e27b1e66',
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/uni-shared/src/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export const UVUE_BUILT_IN_TAGS = [
'uni-slider',
// 原生实现
'button',
'nested-scroll-header',
'nested-scroll-body',
]

export const UVUE_WEB_BUILT_IN_TAGS = [
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 719b642

Please sign in to comment.