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

chore: build

...@@ -12,7 +12,6 @@ declare namespace NodeJS { ...@@ -12,7 +12,6 @@ declare namespace NodeJS {
UNI_CLI_CONTEXT: string UNI_CLI_CONTEXT: string
UNI_SUBPACKAGE?: string UNI_SUBPACKAGE?: string
UNI_MP_PLUGIN?: 'true' UNI_MP_PLUGIN?: 'true'
UNI_MP_UNIAD?: Boolean
UNI_COMPILER_VERSION: string UNI_COMPILER_VERSION: string
UNI_COMPILER_VERSION_TYPE: 'a' | 'r' UNI_COMPILER_VERSION_TYPE: 'a' | 'r'
UNI_HBUILDERX_PLUGINS: string UNI_HBUILDERX_PLUGINS: string
......
...@@ -10,26 +10,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau ...@@ -10,26 +10,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
var initMiniProgramPlugin__default = /*#__PURE__*/_interopDefaultLegacy(initMiniProgramPlugin); var initMiniProgramPlugin__default = /*#__PURE__*/_interopDefaultLegacy(initMiniProgramPlugin);
var path__default = /*#__PURE__*/_interopDefaultLegacy(path); var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
const AD_COMPONENTS = [
'uniad',
'ad-rewarded-video',
'ad-fullscreen-video',
'ad-interstitial',
];
function transformAd(node, context) {
if (!uniCliShared.isElementNode(node)) {
return;
}
const adpidProp = compilerCore.findProp(node, 'adpid');
if (node.tag === 'ad' && adpidProp) {
node.tag = 'uniad';
node.tagType = 1 /* COMPONENT */;
}
if (AD_COMPONENTS.indexOf(node.tag) > -1) {
process.env.UNI_MP_UNIAD = true;
}
}
var uniad_app_json = function (appJson) { var uniad_app_json = function (appJson) {
if (!appJson.plugins) { if (!appJson.plugins) {
appJson.plugins = {}; appJson.plugins = {};
...@@ -57,6 +37,31 @@ var uniad_app_json = function (appJson) { ...@@ -57,6 +37,31 @@ var uniad_app_json = function (appJson) {
var uniadAppJson = uniad_app_json; var uniadAppJson = uniad_app_json;
const AD_COMPONENTS = [
'uniad',
'ad-rewarded-video',
'ad-fullscreen-video',
'ad-interstitial',
];
let appJsonUniadFlag = false;
function transformAd(node, context) {
if (!uniCliShared.isElementNode(node)) {
return;
}
const adpidProp = compilerCore.findProp(node, 'adpid');
if (node.tag === 'ad' && adpidProp) {
node.tag = 'uniad';
node.tagType = 1 /* COMPONENT */;
}
if (appJsonUniadFlag) {
return;
}
if (AD_COMPONENTS.indexOf(node.tag) > -1) {
appJsonUniadFlag = true;
uniadAppJson(uniCliShared.findJsonFile('app'));
}
}
var description = "项目配置文件。"; var description = "项目配置文件。";
var packOptions = { var packOptions = {
ignore: [ ignore: [
...@@ -187,12 +192,6 @@ const options = { ...@@ -187,12 +192,6 @@ const options = {
darkmode: true, darkmode: true,
subpackages: true, subpackages: true,
plugins: true, plugins: true,
normalize(appJson) {
if (process.env.UNI_MP_UNIAD == true) {
uniadAppJson(appJson);
}
return appJson;
},
}, },
project: { project: {
filename: projectConfigFilename, filename: projectConfigFilename,
......
...@@ -10,8 +10,6 @@ import { ...@@ -10,8 +10,6 @@ import {
import { UniMiniProgramPluginOptions } from '@dcloudio/uni-mp-vite' import { UniMiniProgramPluginOptions } from '@dcloudio/uni-mp-vite'
import { transformAd } from './transforms/transformAd' import { transformAd } from './transforms/transformAd'
import uniadAppJson from './uniad.app.json'
import source from './project.config.json' import source from './project.config.json'
export const customElements = [ export const customElements = [
...@@ -100,12 +98,6 @@ export const options: UniMiniProgramPluginOptions = { ...@@ -100,12 +98,6 @@ export const options: UniMiniProgramPluginOptions = {
darkmode: true, darkmode: true,
subpackages: true, subpackages: true,
plugins: true, plugins: true,
normalize(appJson) {
if (process.env.UNI_MP_UNIAD == true) {
uniadAppJson(appJson)
}
return appJson
},
}, },
project: { project: {
filename: projectConfigFilename, filename: projectConfigFilename,
......
import { isElementNode } from '@dcloudio/uni-cli-shared' import { isElementNode, findJsonFile } from '@dcloudio/uni-cli-shared'
import { import {
findProp, findProp,
RootNode, RootNode,
...@@ -14,6 +14,10 @@ const AD_COMPONENTS: Array<string> = [ ...@@ -14,6 +14,10 @@ const AD_COMPONENTS: Array<string> = [
'ad-interstitial', 'ad-interstitial',
] ]
import uniadAppJson from '../uniad.app.json'
let appJsonUniadFlag = false
export function transformAd( export function transformAd(
node: RootNode | TemplateChildNode, node: RootNode | TemplateChildNode,
context: TransformContext context: TransformContext
...@@ -21,12 +25,18 @@ export function transformAd( ...@@ -21,12 +25,18 @@ export function transformAd(
if (!isElementNode(node)) { if (!isElementNode(node)) {
return return
} }
const adpidProp = findProp(node, 'adpid') const adpidProp = findProp(node, 'adpid')
if (node.tag === 'ad' && adpidProp) { if (node.tag === 'ad' && adpidProp) {
node.tag = 'uniad' node.tag = 'uniad'
node.tagType = ElementTypes.COMPONENT node.tagType = ElementTypes.COMPONENT
} }
if (appJsonUniadFlag) {
return
}
if (AD_COMPONENTS.indexOf(node.tag) > -1) { 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.
先完成此消息的编辑!
想要评论请 注册