feat(css): allow specifying stopDir
for postcss config resolution
#11390
+49
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
postcss-load-config has a behavior where it will find any
postcss.config.js
(or other supported postcss configuration formats) recursively from the current directory to the home directory of the user.As of Sanity Studio v3, we're using Vite to power the development experience, and we are seeing quite a large number of reports from people who get an error such as this one upon starting the studio:
This is caused by the user having a postcss configuration file in a parent folder, which while technically speaking is a documented behavior, is not easy to understand or discover for the user.
We are wanting to disable this behavior for our users, instead requiring a postcss configuration to reside inside of the project folder. This can be done by passing a
stopDir
option to cosmicconfig (technically speaking, lilconfig), which is used by postcss-load-config in order to find the configuration file in vite.This PR introduces a new option to the CSS options of vite,
resolveOptions
, which currently only accepts thestopDir
option (the other options did not quite make sense to me in the context of vite on first look, so I decided to limit it for now).Open to other suggestions for how to solve this.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).