postcss/postcss-load-config

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

AlansCodeLog opened this issue · 3 comments

I ask because I ran into vitejs/vite#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

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

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

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.