Skip to content

from id is always cleaned before being passed to the PostCSS plugins #7822

@MadLittleMods

Description

@MadLittleMods

Describe the bug

Nowadays with [email protected]+, we always use cleanUrl(id) which removes extra query parameter information potentially added in the Vite/rollup build steps when we pass the file off to the PostCSS plugins. This behavior was changed in #7173 (specifically).

Before (id) After (cleanUrl(id))
/Users/eric/Documents/github/element/hydrogen-web/src/platform/web/ui/css/themes/element/theme.css?variant=dark&dark=true /Users/eric/Documents/github/element/hydrogen-web/src/platform/web/ui/css/themes/element/theme.css

Before [email protected], we would directly pass the id to the PostCSS from field which plugins can access via root.source.input.from. This old behavior was used in one of our custom PostCSS plugins to filter out certain files based on those ?variant=dark&dark=true query parameters.

I'm wondering if this was a totally intentional change and we need to refactor our PostCSS plugin to work around this? Or if Vite should be adjusted to accommodate again?


Spawned from element-hq/hydrogen-web#722

Reproduction

https://stackblitz.com/edit/vitejs-vite-bswz32?file=my-postcss-plugin.js&terminal=dev

System Info

npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers

  System:
    OS: Windows 10 10.0.19044
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD

Used Package Manager

yarn

Logs

No response

Validations

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions