vite, compiler: Add cssFileFilter option to customize VE module detection - #1773
Open
o-alexandrov wants to merge 1 commit into
Open
vite, compiler: Add cssFileFilter option to customize VE module detection#1773o-alexandrov wants to merge 1 commit into
cssFileFilter option to customize VE module detection#1773o-alexandrov wants to merge 1 commit into
Conversation
…tion The file filter used to detect Vanilla Extract modules was hardcoded to *.css.ts in @vanilla-extract/integration and imported by the Vite plugin and compiler with no way to override it. Expose a cssFileFilter option on vanillaExtractPlugin and createCompiler so a different naming convention (e.g. css.ts) can be used. Defaults to the existing filter, so behaviour is unchanged when omitted.
🦋 Changeset detectedLatest commit: 7e14133 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This was referenced Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds an optional
cssFileFilteroption tovanillaExtractPlugin(@vanilla-extract/vite-plugin) andcreateCompiler(@vanilla-extract/compiler) so consumers can customize which files are treated as Vanilla Extract modules.Today the filter is a hardcoded
constin@vanilla-extract/integration:It's imported directly by the Vite plugin and the compiler, with no way to override it. The new option threads a caller-provided
RegExpthrough both, defaulting to the existing filter so nothing changes when it's omitted.Motivation
We use a single-filename convention (
css.ts) rather than the*.css.tssuffix across a large codebase. With no public way to change the filter, our only option has been to patch@vanilla-extract/integrationon disk after every install (rewriting the regex), which is fragile: a missed copy in a multi-repo/workspace setup silently leavescss.tsfiles untransformed, which surfaces later asStyles were unable to be assigned to a fileat runtime. A first-class option removes the need for that patch.Changes
@vanilla-extract/vite-plugin: newcssFileFilter?: RegExpoption; used in thetransformgate and HMR invalidation, and passed tocreateCompiler.@vanilla-extract/compiler: newcssFileFilter?: RegExponCreateCompilerOptions; used by the module scanner and the internal file-scope transform.cssFileFilter, so it's fully backwards compatible..vanilla.tsfixture that is only recognized via a custom filter, plus a changeset (minor for both packages).Notes
I've read the contributing guide's note that non-trivial changes are ideally discussed first: happy to move this to a discussion/issue if preferred. The change is small, additive, and non-breaking, so I've opened it as a PR to make the proposal concrete. Existing unit tests pass and the changed files are Prettier/oxlint clean.