diff --git a/package.json b/package.json index 51ddfdf..fe18405 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tarojs-plugin-platform-miniprogram", - "version": "0.1.0", + "version": "0.1.1", "description": "@tarojs/plugin-platform-weapp custom wxml support", "main": "dist/index.js", "scripts": { diff --git a/src/index.ts b/src/index.ts index b46b746..d79abd2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,26 +26,27 @@ export default (ctx: IPluginContext, options: Options) => { useConfigName: "mini", async fn({ config }) { config.onBuildFinish = ({ stats }) => { - stats.compilation.entries.forEach((entry) => { + stats?.compilation?.entries?.forEach((entry) => { if (entry.miniType !== "PAGE") return if ( - options.include && + options?.include && !options.include.some((pattern) => entry.name.match(pattern)) ) { return; } if ( - options.exclude && + options?.exclude && options.exclude.some((pattern) => entry.name.match(pattern)) ) { return; } const WxmlFilePath = resolve( - config.outputRoot, + config?.outputRoot ?? 'dist', `${entry.name}.wxml` ); + if (!existsSync(WxmlFilePath)) return; const WxmlFileContent = readFileSync(WxmlFilePath, "utf-8"); let { prefix, suffix } = defaultOptions; if (options?.prefix) {