fix(ct): setting ctTemplateDir does not work (#18152)

closes: https://github.com/microsoft/playwright/issues/18116
This commit is contained in:
sand4rt 2022-11-11 18:52:39 +01:00 committed by GitHub
parent 2e84c63f0d
commit 46559a37c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -291,7 +291,11 @@ function vitePlugin(registerSource: string, relativeTemplateDir: string, buildIn
return { code, map: { mappings: '' } };
}
if (!id.endsWith(`${relativeTemplateDir}/index.ts`) && !id.endsWith(`${relativeTemplateDir}/index.tsx`) && !id.endsWith(`${relativeTemplateDir}/index.js`))
const indexTs = path.join(relativeTemplateDir, 'index.ts');
const indexTsx = path.join(relativeTemplateDir, 'index.tsx');
const indexJs = path.join(relativeTemplateDir, 'index.js');
const idResolved = path.resolve(id);
if (!idResolved.endsWith(indexTs) && !idResolved.endsWith(indexTsx) && !idResolved.endsWith(indexJs))
return;
const folder = path.dirname(id);