postcss / postcss-load-config

Autoload Config for PostCSS
MIT License
638 stars 71 forks source link

Is it intended that the package search up the user path by default? #245

Closed AlansCodeLog closed 1 year ago

AlansCodeLog commented 1 year ago

I ask because I ran into https://github.com/vitejs/vite/issues/13302 when a package (A) is inside another package(B) with a postcss config but package A does not have a postcss config, it tries to load package B's config. This happens because lilconfig/cosmiconfig has an option stopDir that by default is set to the user's home dir.

Reproduction (Code)

git clone https://github.com/alanscodelog/postcss-bug
cd inner-package
npm i
node index.ts

If you uncomment stopDir in the inner-package/index.ts file you can see the error stops.

ai commented 1 year ago

But setting stopDir to current root will break monorepo support (where developers put PostCSS config to the root package).

AlansCodeLog commented 1 year ago

:+1: That makes sense. I'm not that familiar with postcss and how it's used in monorepos. Was asking just to be sure.

joshmanders commented 9 months ago

This bit me IN a monorepo because it ignored the package.json in the package it was in and searched for it in the root package.json instead.

I had to move the config to the root package.json and that's not ideal.