fix(vite): throw informative error if no vitest config exists (#19819)

This commit is contained in:
Katerina Skroumpelou 2023-10-24 16:07:39 +03:00 committed by GitHub
parent 742b9a1bcb
commit f1f0f15f0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -130,6 +130,18 @@ async function getSettings(
? options.config // config is expected to be from the workspace root
: findViteConfig(joinPathFragments(context.root, projectRoot));
if (!viteConfigPath) {
throw new Error(
stripIndents`
Unable to load test config from config file ${viteConfigPath}.
Please make sure that vitest is configured correctly,
or use the @nx/vite:vitest generator to configure it for you.
You can read more here: https://nx.dev/nx-api/vite/generators/vitest
`
);
}
const resolvedProjectRoot = resolve(workspaceRoot, projectRoot);
const resolvedViteConfigPath = resolve(
workspaceRoot,

View File

@ -155,8 +155,13 @@ export function getViteBuildOptions(
const projectRoot =
context.projectsConfigurations.projects[context.projectName].root;
const outputPath = joinPathFragments(
'dist',
projectRoot != '.' ? projectRoot : context.projectName
);
return {
outDir: relative(projectRoot, options.outputPath),
outDir: relative(projectRoot, options.outputPath ?? outputPath),
emptyOutDir: options.emptyOutDir,
reportCompressedSize: true,
cssCodeSplit: options.cssCodeSplit,