Skip to content

Commit

Permalink
Improve error message for invalid patterns (#4556)
Browse files Browse the repository at this point in the history
This error message felt really confusing to me and even while reading
the documentation, it was unclear how I could get my entries to be
stored in a subdirectory. I added this little hint to the error message
so that others may not run into the same issue.

Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
  • Loading branch information
DysphoricUnicorn and lukastaegert committed Jul 8, 2022
1 parent 2b399ff commit 4bab4ac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utils/renderNamePattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function renderNamePattern(
if (isPathFragment(pattern))
return error(
errFailedValidation(
`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths.`
`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`
)
);
return pattern.replace(/\[(\w+)\]/g, (_match, type) => {
Expand Down
2 changes: 1 addition & 1 deletion test/function/samples/invalid-pattern/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = {
generateError: {
code: 'VALIDATION_ERROR',
message:
'Invalid pattern "../main.js" for "output.entryFileNames", patterns can be neither absolute nor relative paths.'
'Invalid pattern "../main.js" for "output.entryFileNames", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.'
}
};

0 comments on commit 4bab4ac

Please sign in to comment.