支持小程序app.json中tabbar的iconpath路径解析
This commit is contained in:
parent
6f3b196b96
commit
1d1328cb5d
|
|
@ -20,6 +20,12 @@ module.exports = (babel) => {
|
|||
/index\.(ts|js)$/,
|
||||
'web.js'
|
||||
);
|
||||
const xmlFile = filename.replace(
|
||||
/index\.(ts|js)$/,
|
||||
'index.xml'
|
||||
);
|
||||
const xmlFileExists = fs.existsSync(xmlFile);
|
||||
|
||||
const tsxFileExists = fs.existsSync(tsxFile);
|
||||
const jsFileExists = fs.existsSync(jsFile);
|
||||
const pcTsxFile = filename.replace(
|
||||
|
|
@ -194,7 +200,7 @@ module.exports = (babel) => {
|
|||
statements.push(...renderJsStatements);
|
||||
} else if (pcJsFileExists) {
|
||||
statements.push(...renderPcJsStatements);
|
||||
} else {
|
||||
} else if (!xmlFileExists) {
|
||||
assert(
|
||||
false,
|
||||
`${filename}文件中不存在web.tsx或者web.pc.tsx`
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ function makeRouterItem(page, ns, namespacePath, first) {
|
|||
t.arrowFunctionExpression(
|
||||
[],
|
||||
t.callExpression(t.import(), [
|
||||
t.stringLiteral(join('@project', 'pages', ns, path, 'index').replace(/\\/g, '/'))
|
||||
t.stringLiteral(join(AppPaths.appRootSrc, 'pages', ns, path, 'index').replace(/\\/g, '/'))
|
||||
])
|
||||
),
|
||||
]
|
||||
|
|
@ -271,7 +271,7 @@ module.exports = () => {
|
|||
t.arrowFunctionExpression(
|
||||
[],
|
||||
t.callExpression(t.import(), [
|
||||
t.stringLiteral(join('@project', 'pages', ns, notFound, 'index').replace(/\\/g, '/'))
|
||||
t.stringLiteral(join(AppPaths.appRootSrc, 'pages', ns, notFound, 'index').replace(/\\/g, '/'))
|
||||
])
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -184,12 +184,15 @@ class OakWeChatMpPlugin {
|
|||
let realPages = [];
|
||||
this.subpackRoot = [];
|
||||
|
||||
for (const { iconPath, selectedIconPath } of tabBar.list || []) {
|
||||
for (const tab of tabBar.list || []) {
|
||||
const { iconPath, selectedIconPath, pagePath } = tab;
|
||||
if (iconPath) {
|
||||
tabBarAssets.add(iconPath);
|
||||
const aliasPath = this.getAliasPath(iconPath);
|
||||
tabBarAssets.add(aliasPath);
|
||||
}
|
||||
if (selectedIconPath) {
|
||||
tabBarAssets.add(selectedIconPath);
|
||||
const aliasPath = this.getAliasPath(selectedIconPath);
|
||||
tabBarAssets.add(aliasPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +360,7 @@ class OakWeChatMpPlugin {
|
|||
ignore: this.getIgnoreExt(),
|
||||
dot: false,
|
||||
});
|
||||
|
||||
|
||||
this.assetsEntry = [...entries, ...this.appEntries.tabBarAssets];
|
||||
this.assetsEntry.forEach((resource) => {
|
||||
new EntryPlugin(
|
||||
|
|
@ -543,6 +546,23 @@ class OakWeChatMpPlugin {
|
|||
appJson.pages = pages;
|
||||
}
|
||||
|
||||
if (appJson.tabBar) {
|
||||
const list = appJson.tabBar.list;
|
||||
|
||||
for (const tab of list || []) {
|
||||
const { iconPath, selectedIconPath, pagePath } = tab;
|
||||
if (iconPath) {
|
||||
tab.iconPath = this.getReplaceAlias(iconPath);
|
||||
}
|
||||
if (selectedIconPath) {
|
||||
tab.selectedIconPath = this.getReplaceAlias(selectedIconPath);
|
||||
}
|
||||
if (pagePath) {
|
||||
tab.pagePath = this.getReplaceAlias(pagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let usingComponents = {};
|
||||
if (appJson.usingComponents) {
|
||||
for (let ck of Object.keys(appJson.usingComponents)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue