diff --git a/packages/taro-vite-runner/src/harmony/asset.ts b/packages/taro-vite-runner/src/harmony/asset.ts index bfb056f5eab..60ff16a9802 100644 --- a/packages/taro-vite-runner/src/harmony/asset.ts +++ b/packages/taro-vite-runner/src/harmony/asset.ts @@ -279,8 +279,9 @@ export function fileToUrl( // const url = `__TARO_VITE_ASSET__${referenceId}__${postfix ? `$_${postfix}__` : ``}` // TODO_BASE - const resourceName = path.relative(appRoot, file).replace(/^[\\/]+/, '').replace(/[^A-z0-9]+/g, '_') - const resourcePath = path.join(escapePath(outputRoot), '..', 'resources/base/media', resourceName) + const ext = path.extname(file) + const resourceName = path.relative(appRoot, file).replace(ext, '').replace(/^[\\/]+/, '').replace(/[^A-z0-9]+/g, '_') + const resourcePath = path.join(escapePath(outputRoot), '..', 'resources/base/media', `${resourceName}${ext}`) fs.ensureDirSync(path.dirname(resourcePath)) fs.writeFileSync(resourcePath, content, { encoding: 'utf-8', diff --git a/packages/taro-vite-runner/src/harmony/page.ts b/packages/taro-vite-runner/src/harmony/page.ts index 7c853b84156..0aa35301475 100644 --- a/packages/taro-vite-runner/src/harmony/page.ts +++ b/packages/taro-vite-runner/src/harmony/page.ts @@ -22,7 +22,7 @@ const nativeUniqueKeyMap = new WeakMap>() export default function (viteCompilerContext: ViteHarmonyCompilerContext): PluginOption { const name = 'taro:vite-harmony-page' const { taroConfig, sourceDir } = viteCompilerContext - const filter = createFilterWithCompileOptions(taroConfig.compile, [sourceDir, /(?<=node_modules[\\/]).*taro/], []) + const filter = createFilterWithCompileOptions(taroConfig.compile, [`${sourceDir}/**`, /(?<=node_modules[\\/]).*taro/], []) let viteConfig: ResolvedConfig let nCompCache: Map>