fix(vite): throw informative error if no vitest config exists (#19819)
This commit is contained in:
parent
742b9a1bcb
commit
f1f0f15f0a
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user