Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export PostCSS config type from postcss-load-config #19109

Open
4 tasks done
benedictleejh opened this issue Dec 31, 2024 · 1 comment
Open
4 tasks done

Re-export PostCSS config type from postcss-load-config #19109

benedictleejh opened this issue Dec 31, 2024 · 1 comment
Labels
enhancement New feature or request feat: css

Comments

@benedictleejh
Copy link

Description

As a developer using Vite I want to be able to write type-safe PostCSS configs using the same version of postcss-load-config Vite uses so that I do not accidentally write configs that Vite cannot load correctly.

Suggested solution

In Vite, we could re-export the type postcssrc.Config from postcss-load-config so that developers can use that type to write type-safe PostCSS configs.

Alternative

  • Not vendor postcss-load-config code (as suggested in ESM .postcssrc.ts w. "type": "module" results in ERR_REQUIRE_ESM #15869 (comment))
  • Writing PostCSS config inside Vite config
    • This only accepts the array format, and many examples use the object format; converting from the object format to the array format is not the most straightforward, especially if plugin options are involved
    • On a more subjective note, I prefer having each tool's config in a separate file, as it helps me mentally separate the context I need to consider
  • Adding a devDependency on postcss-load-config per project to get access to the type in each project using PostCSS
    • This requires that all projects using Vite keep track of the version of postcss-load-config used by Vite to not use a wrong version and accidentally write a wrong config
  • Not writing type-safe configs

Additional context

Now that Vite 6 has updated postcss-load-config to v6, developers can now load TypeScript PostCSS config files easily, but ensuring that these configs are type-safe require us to add an additional dependency on postcss-load-config, which is less than ideal due to the possibility of a project's postcss-load-config differing from Vite's, which can lead to hard to debug errors.

Validations

@bluwy
Copy link
Member

bluwy commented Jan 2, 2025

Sounds like a good idea to me 👍

@bluwy bluwy added enhancement New feature or request feat: css and removed enhancement: pending triage labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat: css
Projects
None yet
Development

No branches or pull requests

2 participants