Skip to content

Commit

Permalink
fix: should check skeleton file existed before read (#7021)
Browse files Browse the repository at this point in the history
  • Loading branch information
XGHeaven authored Nov 19, 2024
1 parent 2e27496 commit cce46e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-dots-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/plugin-miniapp': patch
---

fix: should check skeleton file existed before read
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ export default class MiniPlugin {
path: pagePath,
isNative,
stylePath: isNative ? this.getStylePath(pagePath) : undefined,
templatePath: isNative ? this.getTemplatePath(pagePath) : undefined,
skeletonPath: isNative ? this.getSkeletonExtraPath(pagePath) : undefined,
};
}),
Expand Down Expand Up @@ -690,10 +691,10 @@ export default class MiniPlugin {
}
this.addEntry(path.resolve(__dirname, '..', 'template/custom-wrapper'), 'custom-wrapper', META_TYPE.STATIC);

const resolveComponentStyleEntry = (name: string, stylePaths: string[]) => {
const resolveComponentStyleEntry = (name: string, stylePaths: string[], ext = this.options.fileType.style) => {
for (const stylePath of stylePaths) {
if (fs.existsSync(stylePath)) {
this.addEntry(stylePath, this.getTargetFilePath(name, this.options.fileType.style), META_TYPE.NORMAL);
this.addEntry(stylePath, this.getTargetFilePath(name, ext), META_TYPE.NORMAL);
break;
}
}
Expand All @@ -709,12 +710,10 @@ export default class MiniPlugin {
this.addEntry(item.templatePath, this.getTemplatePath(item.name), META_TYPE.NORMAL);
}

if (item.skeletonPath) {
if (item.skeletonPath.template) {
this.addEntry(item.skeletonPath.template, this.getTargetFilePath(item.name, `${this.options.fileType.skeletonMidExt}${this.options.fileType.templ}`), META_TYPE.NORMAL);
}
if (item.skeletonPath && item.skeletonPath.template && fs.existsSync(item.skeletonPath.template)) {
this.addEntry(item.skeletonPath.template, this.getTargetFilePath(item.name, `${this.options.fileType.skeletonMidExt}${this.options.fileType.templ}`), META_TYPE.NORMAL);
if (item.skeletonPath.style) {
resolveComponentStyleEntry(this.getTargetFilePath(item.name, this.options.fileType.skeletonMidExt), item.skeletonPath.style);
resolveComponentStyleEntry(item.name, item.skeletonPath.style, `${this.options.fileType.skeletonMidExt}${this.options.fileType.style}`);
}
}
} else {
Expand Down

0 comments on commit cce46e9

Please sign in to comment.