提交 a8b0667e 编写于 作者: d-u-a's avatar d-u-a

fix: vue3 mp-weixin ad 更新 app.json 逻辑

上级 0ce7e37a
......@@ -12,7 +12,6 @@ declare namespace NodeJS {
UNI_CLI_CONTEXT: string
UNI_SUBPACKAGE?: string
UNI_MP_PLUGIN?: 'true'
UNI_MP_UNIAD?: Boolean
UNI_COMPILER_VERSION: string
UNI_COMPILER_VERSION_TYPE: 'a' | 'r'
UNI_HBUILDERX_PLUGINS: string
......
......@@ -10,8 +10,6 @@ import {
import { UniMiniProgramPluginOptions } from '@dcloudio/uni-mp-vite'
import { transformAd } from './transforms/transformAd'
import uniadAppJson from './uniad.app.json'
import source from './project.config.json'
export const customElements = [
......@@ -100,12 +98,6 @@ export const options: UniMiniProgramPluginOptions = {
darkmode: true,
subpackages: true,
plugins: true,
normalize(appJson) {
if (process.env.UNI_MP_UNIAD == true) {
uniadAppJson(appJson)
}
return appJson
},
},
project: {
filename: projectConfigFilename,
......
import { isElementNode } from '@dcloudio/uni-cli-shared'
import { isElementNode, findJsonFile } from '@dcloudio/uni-cli-shared'
import {
findProp,
RootNode,
......@@ -14,6 +14,10 @@ const AD_COMPONENTS: Array<string> = [
'ad-interstitial',
]
import uniadAppJson from '../uniad.app.json'
let appJsonUniadFlag = false
export function transformAd(
node: RootNode | TemplateChildNode,
context: TransformContext
......@@ -21,12 +25,18 @@ export function transformAd(
if (!isElementNode(node)) {
return
}
const adpidProp = findProp(node, 'adpid')
if (node.tag === 'ad' && adpidProp) {
node.tag = 'uniad'
node.tagType = ElementTypes.COMPONENT
}
if (appJsonUniadFlag) {
return
}
if (AD_COMPONENTS.indexOf(node.tag) > -1) {
process.env.UNI_MP_UNIAD = true
appJsonUniadFlag = true
uniadAppJson(findJsonFile('app'))
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册